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.
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