vendredi 19 février 2021

How to a update multiple rows where value is equal to 1 in Laravel

I am trying to update multiple rows in table where role is equal to 3 but it seems not working properly. So what i am trying to achieve is first get all the users, then get members from members tables where school_id is equal to to school_id inside users table and user_id is equal to id in user table. Then update all rows that match the criteria.

public function updateOwnrsRole()
{
    $users = Users::all();

    foreach ($users as $user) {
        $members = Member::where('school_id', $user->id)
                               ->where('user_id', $user->created_at)
                               ->update(['role', 3]);
        return $members;
    }

}

}



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

Aucun commentaire:

Enregistrer un commentaire