samedi 20 février 2021

How to update multiple rows in laravel

I would like to update existing records in a table where userID and where classID.

$users = User::all(); //Get all users;

$userClasses = UserClass::whereIn('classID', 'users->class_id)
                        ->whereIn('userID', 'users->is)
                        ->update('role' => 3);

But I get error Property [id] does not exist on this collection instance. I know it is because $users is a collection of object and that is why it returns this error. But What is the best way to achieve this? Thanks in advance



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire