auth = $auth; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { # Checks to see if the current user is a moderator or an administrator if (!Auth::user()->hasPosition('mod', 'admin')) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { # Return ack if the user is not a moderator or administrator return redirect()->back()->with('info', 'You are not allowed to view that page!'); } } return $next($request); } }