Level 26
Updated
DB::table('mails')->update(['mark' => 0]);
You can't call save() on a Collection.
Edit: Just seen you figured it out :)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi,
I am trying to update all fields in same time in table column. First, i check are there diferent values(0 or 1) if are all 1, then update all values to 0. I try with this part of code,but get error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to undefined method Illuminate\Database\Eloquent\Collection::save()
Here is my code:
$users = DB::table('mails')->distinct('mark')->count('mark');
if ($users == 1){
$mark = Mails::all();
$mark->mark = '0';
$mark->save();
echo 'reset values to 0';
}else{
echo 'DIferent values';
}
Tnx,
Updated
DB::table('mails')->update(['mark' => 0]);
You can't call save() on a Collection.
Edit: Just seen you figured it out :)
Please or to participate in this conversation.