'ID' => [9, 8, 7, 6, 5...]
class ProjectService
{
public function addUserInProject(int $projectId, int $userId)
{
$project = Project::find($projectId);
if (\Auth::user()->can('access', $project) == false) {
throw new \Exception();
}
$project->users()->attach($userId);
}
public function deleteUserFromProject(int $projectId, int $userId)
{
$project = Project::find($projectId);
if (\Auth::user()->can('access', $project) == false) {
throw new \Exception();
}
$project->users()->detach($userId);
}
}