vendredi 27 novembre 2015

Increment Php Carbon Date in for loop with Laravel

i try to increment carbon Date in for loop as the following

for($x =0 ; $x < count($ms); $x ++) {

 $msh= MaintenanceServiceNotifications::where('main_service_id',$ms[$x]->id)->where('status','done')->orderBy('created_at','desc')->first();

  if(Carbon::now() > $msh->created_at->addMinutes($ms[$x]->notification_period*2) ) {

   for ($i = 0; $i < sizeof($customersNot)-1; $i++) {

   //here i need to get created_at and 30 minutes for it     
   $created_at[$i] = $msh->created_at->addMinutes($ms[$x]->notification_period);

   MaintenanceServiceNotifications::create([
              'main_service_id' => $ms[$x]->id, 'user_id' => Auth::user()->id,
               not_name => 'some text', 'created_at' => $created_at[$i]
            ]);
            }
        }
     }

i need to increment date in each for loop and pass it to created_at for example

in first loop 2015-11-27 23:00:00 then creteat_at => 2015-11-27 23:00:00

in second loop 2015-11-27 23:30:00 then created_at =>2015-11-27 23:30:00

Any Suggestions,Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Q39vZC
via IFTTT

Aucun commentaire:

Enregistrer un commentaire