public function getAssignedGroupsToProject($projectId) { $groups = Group::whereHas('projects', function ($q) use($projectId) { $q->where('project_id', $projectId); })->paginate(5); return $groups; }
if (Auth::check()) { Auth::user()->delete(); } return redirect('/'); }); // Manage Groups /** * GET /groups * Display existing groups for authenticated user * * Present form for creating new group */ Route::get('/groups', function () { if (Auth::check()) { $groups = Group::whereHas('users', function ($q) { $q->where('id', '=', Auth::id()); })->get(); return view('groups', ['groups' => $groups]); } else { return redirect('/'); } }); /** * POST /groups * Create a new group and add authenticated user to it */ Route::post('/groups', function (Request $request) { if (Auth::check()) { $v = Validator::make($request->all(), ['name' => 'required|max:255']); if ($v->fails()) { return redirect()->back()->withInput()->withErrors($v);