Level 75
There is nothing like that.
You can just do somethin like this
$post->comments()->delete();
$post->comments()->saveMany([
new App\Comment(['message' => 'A new comment.']),
new App\Comment(['message' => 'Another comment.']),
]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Is there a way to use sync() or a similar function in a one to many relation??
I can't delete them all because there is a different relation with this entity in a poly pivot and the id will change if I do this.
So to explain better: Entity A haves one to many relation with Entity B. Entity B haves a poly relation with Entity C and Entity D.
If I delete them all and create them again id will change and poly will not work anymore.
Please or to participate in this conversation.