Like this?
DB::table('user_to_list')->where('user_id', $user->id)->whereIn('list_id', $listOfIds)->update([
'column' => 1
]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 3 tables: users, lists and user_to_list
I am given array of ids of lists. in the user_to_list table this id is referred to as list_id
I need to update all the rows in specific column to value 1 in the user_to_list table for a user given the array of list_ids
What is the correct query?
I tried a few variations that start with
$user->userToList->where.. // but got stuck here (failed)
(The relationships are set correctly including the userToList)
Like this?
DB::table('user_to_list')->where('user_id', $user->id)->whereIn('list_id', $listOfIds)->update([
'column' => 1
]);
Please or to participate in this conversation.