public function ModulesPage($user_id) { $user = UserMod::where('id', $user_id)->where('role', '=', 'Administrator')->first(); if (UserMod::where('id', $user_id)->where('role', '=', 'Administrator')->exists()) { if (Module::exists()) { $modules = Module::with('user')->get(); } else { $modules = Module::get(); Session::flash('no_modules', "There are no existed modules in our records"); } return View::make("Admin-modules")->with('modules', $modules)->with('user', $user); } else { Session::flash('failed', "Something went wrong, please try again!"); return back()->withInput(); } }