untymage
2 months ago
219
4
Laravel

syncWithoutDetaching not working correctly

Posted 2 months ago by untymage
$this->actors()->syncWithoutDetaching([1 => ['role' => 1]]);

$this->actors()->syncWithoutDetaching([1 => ['role' => 2]]);

I want to attach an actor in multiple role in pivot table, But syncWithoutDetaching replace and detach the previous record why ? Shouldn't it not detach anything ?

Please sign in or create an account to participate in this conversation.