diff --git a/app/Http/Controllers/AjaxController.php b/app/Http/Controllers/AjaxController.php index a4f1195..6b63c05 100644 --- a/app/Http/Controllers/AjaxController.php +++ b/app/Http/Controllers/AjaxController.php @@ -134,11 +134,7 @@ class AjaxController extends Controller $mur->save(); // Sauvegarde de stat - $stat = new Statistique(); - $stat->stat_campId = $campagne->camp_id; - $stat->stat_couponId = $cp->coupon_id; - $stat->stat_couponPrinted = 1; - $stat->save(); + $this->saveStat($campagne, $cp); }//end if }//end foreach } elseif ($campagne->camp_type->equals(CampaignTypes::panier())) { @@ -171,11 +167,7 @@ class AjaxController extends Controller array_push($couponsPrinted, ['cp_code' => $cp->coupon_code, 'qty' => $panierContent->panier_content_quantity]); // Sauvegarde de stat - $stat = new Statistique(); - $stat->stat_campId = $campagne->camp_id; - $stat->stat_couponId = $cp->coupon_id; - $stat->stat_couponPrinted = $panierContent->panier_content_quantity; - $stat->save(); + $this->saveStat($campagne, $cp); } else { if ($panierContent->panier_content_quantity > 0) { $coupons .= ''; @@ -188,11 +180,7 @@ class AjaxController extends Controller array_push($couponsPrinted, ['cp_code' => $cp->coupon_code, 'qty' => 1]); // Sauvegarde de stat - $stat = new Statistique(); - $stat->stat_campId = $campagne->camp_id; - $stat->stat_couponId = $cp->coupon_id; - $stat->stat_couponPrinted = 1; - $stat->save(); + $this->saveStat($campagne, $cp); } }//end if // ---- Mémorise l'impression @@ -233,11 +221,7 @@ class AjaxController extends Controller $mur->save(); // Sauvegarde de stat - $stat = new Statistique(); - $stat->stat_campId = $campagne->camp_id; - $stat->stat_couponId = $cp->coupon_id; - $stat->stat_couponPrinted = 1; - $stat->save(); + $this->saveStat($campagne, $cp); }//end if }//end foreach } elseif ($campagne->camp_type->equals(CampaignTypes::paniers())) { @@ -265,11 +249,7 @@ class AjaxController extends Controller $newQtyPrinted = $panierContent->panier_content_printed + 1; // Sauvegarde de stat - $stat = new Statistique(); - $stat->stat_campId = $campagne->camp_id; - $stat->stat_couponId = $cp->coupon_id; - $stat->stat_couponPrinted = 1; - $stat->save(); + $this->saveStat($campagne, $cp); } array_push($couponsPrinted, ['cp_code' => $cp->coupon_code, 'qty' => 1]); // ---- Mémorise l'impression