user(); //超级管理员过 if($admin->hasPermissionTo('root', $guard)) { return $next($request); } $except_controller=['/admin/home/index','/admin/home/home']; foreach ($except_controller as $v) { if($v==$this->getRouteInfo()) { return $next($request); } } //权限判断 if(!$admin->hasPermissionTo($permission)) { abort(401,'没有权限'); } return $next($request); } public function getRouteInfo($type=0){ $arr=[]; $route_arr=explode('@', Route::currentRouteAction()); $arr['controller']=str_replace('Controller','',str_replace('App\\Http\\Controllers\\Admin\\','',$route_arr[0])); $arr['action']=$route_arr[1]; if($type==1) { return strtolower($arr['action']); } return strtolower(implode('/',$arr)); } }