excludeList as $item) { if (strpos($request->url(), $item) !== false) { if (!Admin::user()->isAdministrator()) { throw new NotFoundHttpException; // 触发404 } } } //判断是否登录,如果getDistributor不存在,则触发登录页面 if (Admin::user()) { if (!getDistributor()) { if (strpos($request->url(), 'auth/logout') == false) { // 存在时的逻辑 return redirect('/dist/auth/logout'); } } } //否则继续处理当前请求 return $next($request); } }