Level 24
Nov 10, 2018
2
Level 1
Eloquent sync() method does separate insert\update query for each item
When i try to update several items in pivot table, using sync(), each insert\update is done with a separate sql query. Is there any way to make it work as a single query, without adding additional logic?
$skills = [1 => ['experience' => 5], 2 => ['experience' => 7]];
$user->skills()->sync($skills);
produces 2 queries instead of one combined:
insert into user_skills ...
insert into user_skills ...
Please or to participate in this conversation.