ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
如果我们要使用中间件可以自己创建一个 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`