1
public function postWorkerActivityPlus()
{
$current = Carbon::now();
$WorkerActivity = Model::where('at_work',1)->where('updated_at','<',$current)->get();
$d = $a/$b * $c ;
foreach ($WorkerActivity as $key => $wa) {
$updateActivity = Model::find($wa->id);
if ($wa->worker_activity <= $a) {
$updateActivity->worker_activity += $d;
$updateActivity->save();
return redirect()->back()->with('info', 'You updated worker');
}
}
}
這一結果更新第一$ updateActivity,當第一worker_activity達到$一,繼續第二個等等。我的任務更新一次全部更新所有行
你真正的問題是什麼? – joanolo