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



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3pEbGs7
via IFTTT

Aucun commentaire:

Enregistrer un commentaire