Fix datestart to check for each campaign
This commit is contained in:
parent
8ed79f1884
commit
f8a389637b
1 changed files with 8 additions and 6 deletions
|
|
@ -109,14 +109,16 @@ class Kernel extends ConsoleKernel
|
|||
|
||||
// ---- Sauvegarde des stats tous les jours a 23:45
|
||||
$schedule->call(function () {
|
||||
$last_stat = Statistique::orderBy('created_at', 'DESC')->first();
|
||||
if(isset($last_stat->created_at)){
|
||||
$dateStart = $last_stat->created_at;
|
||||
} else {
|
||||
$dateStart = Carbon::now()->setTime(0,0,0)->subMonth()->format('Y-m-d H:i:s');
|
||||
}
|
||||
$campagnes = Campagne::all();
|
||||
foreach ($campagnes as $campagne) {
|
||||
|
||||
$last_stat = Statistique::where(['stat_campId' => $campagne->camp_id])->orderBy('created_at', 'DESC')->first();
|
||||
if(isset($last_stat->created_at)){
|
||||
$dateStart = $last_stat->created_at;
|
||||
} else {
|
||||
$dateStart = Carbon::now()->setTime(0,0,0)->subMonth()->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
$coupons = $campagne->coupons()->get();
|
||||
foreach ($coupons as $coupon) {
|
||||
if ($campagne->camp_type == 0 || $campagne->camp_type == 2) { //Calcul des BR consommé pour les murs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue