You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: