/** * Show the admin panel, and process admin AJAX requests. * * @return Response */ public function displayAdminPage(Request $request) { if (!$this->isLoggedIn()) { return abort(404); } $username = session('username'); $role = session('role'); $admin_users = null; $admin_links = null; if ($this->currIsAdmin()) { $admin_users = User::paginate(15); $admin_links = Link::paginate(15); } $user = UserHelper::getUserByUsername($username); if (!$user) { return redirect(route('index'))->with('error', 'Invalid or disabled account.'); } $user_links = Link::where('creator', $username)->paginate(15); return view('admin', ['role' => $role, 'admin_users' => $admin_users, 'admin_links' => $admin_links, 'user_links' => $user_links, 'api_key' => $user->api_key, 'api_active' => $user->api_active, 'api_quota' => $user->api_quota]); }