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 an administrator if (!Auth::user()->hasPosition('admin')) { if ($request->ajax()) { return response('Unauthorized.', 401); } else { # Return ack if the user is not an administrator return redirect()->back()->with('info', 'You are not allowed to view that page!'); } } return $next($request); } }