I have an array of objects in my Laravel controller. I need to loop over each object in the array and set the 'status' of each object to 0. I have the following in my controller:
if (request('status')=='Reset') {
$allDemoTasks = DemoTask::all();
foreach($allDemoTasks as $index=>$key)
$key->status=0;
$key->save();
}
It appears to be setting the last object in my array to 0 and not doing anything to the other objects.