我有表(projects, roles, scopes, shifts, users)
和表(project_role_scope_shift_user)
作为枢轴。
我要删除特定行,例如:
[project_id = 1 , scope_id = 2 , ... ]
但是,分离方法无法正常工作。
$user->roles()->detach(role) !not working => removes all rows of that role
$user->roles()->detach(role, ['project_id' => $projectId, 'scope_id' => $scopeId, 'shift_id' => $shiftId]); => this does not work too, removes all rows of that role
答案 0 :(得分:1)
尝试一下:
$user->roles()->wherePivot(['project_id' => $projectId, 'scope_id' => $scopeId, 'shift_id' => $shiftId])->detach();