Open noecs opened 3 years ago
I did not quite understood the request. First of all, sync
is for many-to-many relationships, not for one-to-many and it already supports additional fields to be updated on the pivot table (code taken from the docs linked before):
$user->roles()->sync([1 => ['expires' => true], 2, 3]);
Therefore your code could be:
$product->sku()->sync([
'123123' => [
'status' => true,
'stock' => 100,
],
]);
When I use
Eloquent saveMany
, I am thinking if a product has manysku
, and every time I save, whether it can be like a many-to-many relationship, I can usesync
to synchronize the one-to-many relationship . It looks like this: