laravel-pivot-softdeletes icon indicating copy to clipboard operation
laravel-pivot-softdeletes copied to clipboard

Detaching twice

Open Ir00man opened this issue 3 years ago • 2 comments

Do you think that detach() method should detach all related models OR only those are attached? I mean if call something like this: Post::find(495)->tags()->detach(); twice deleted_at column will be updated 2 times. Can we leave records untouched in pivot table when they are already deleted (deleted_at column != null)?

Ir00man avatar May 26 '21 16:05 Ir00man

Actually my problem can be solved by using Post::find(495)->tags()->sync([]); This way deleted_at column will not be updated if it's not empty. But still do you think that detach() method should respect already deleted records and keep them as is?

Ir00man avatar May 26 '21 16:05 Ir00man

I think this is good idea.

feel free to make PR with changes

ddzobov avatar May 26 '21 17:05 ddzobov