php-laravel中间件使用

中间件使用
    1、项目目录下cmd中php artisan make:middleware adminLogin,创建中间件
    
    2、注册中间件(Httpkernel.php)
        protected $routeMiddleware = [
            'throttle' => IlluminateRoutingMiddlewareThrottleRequests::class,
            'adminLogin' => AppHttpMiddlewareAdminLogin::class,
        ];
    3、在group组中加入中间件过滤路由
     Route::group(['namespace'=>'admin','prefix'=>'admin','middleware'=>'adminLogin'],function(){
    }
    4、打开中间件即可编辑方法(appHttpMiddlewareadminLogin.php)
原文地址:https://www.cnblogs.com/somethingWithiOS/p/10573574.html