public function getNotAssignedGroupsToProject($projectId) { $groups = Group::whereDoesntHave('projects', function ($q) use($projectId) { $q->where('project_id', $projectId); })->paginate(5); return $groups; }