/** * Display the specified resource. * * @param $username * @internal param int $id * @return Response */ public function show($username) { try { $user = Auth::user()->with('projects')->where('user_name', $username)->firstOrFail(); } catch (ModelNotFoundException $e) { return Redirect::home(); } // Take the Administrator to the admin panel. if ($user->id == '2') { return redirect('admin'); } $contributions = Pledge::where('user_id', '=', $user->id)->get(); $favourites = Favourite::with('project')->where('user_id', '=', $user->id)->get(); // if it's a regular user, redirect to user's dashboard return view('userpanel.index', compact('user', 'contributions', 'favourites')); }