🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
如果我们要使用中间件可以自己创建一个 php artisan make:middleware 中间件名字 `php artisan make:middleware AdminLogin` 可以在对应文件夹里面看到 `app\Http\Middleware\AdminLogin.php` 我们还要注册下 ~~~ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'can' => \Illuminate\Foundation\Http\Middleware\Authorize::class, 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, 'AdminLogin'=>\App\Http\Middleware\AdminLogin::class, ]; ~~~ 我们自己创建的中间件一般是写在 `$routeMiddleware`