mlezcano1985 / laravel-pivot-soft-deletes

(DEPRECATED) Soft delete Eloquent pivot models using Laravel SoftDeletes trait
MIT License
18 stars 5 forks source link

Doesn't work on sync() #1

Open supanida opened 6 years ago

supanida commented 6 years ago

The intermediate pivot table doesn't do soft delete when using sync(). For example(), public function dept() { return $this->belongsToMany('App\Dept', 'user_dept', 'user_id', 'dept_id'); }

User is in many to many relation on Dept. Both User and Dept use SoftDeletes, PivotSoftDeletes; $user = User::find(1); $user->dept()->sync([3, 2, 8, 4]); // --> this will attach dept id, 3, 2, 8, 4 to the pivot table for user id 1 $user->dept()->sync([3, 2, 9, 4]); // --> this should put delete_at for dept id 8 and add row with dept id 9 in the pivot table

But after I run it, it instead deleted dept id 8 and add dept id 9 in the pivot table.

Note: I use laravel 5.6

rogervila commented 6 years ago

+1