Laravel Middleware(中间件)

1、创建中间件

php artisan make:middleware AdminCheck

2、注册中间件(Kernel.php)

 protected $routeMiddleware = [
     
        'admincheck' => \App\Http\Middleware\AdminCheck::class,
    ];

3、使用中间件

Route::namespace('Admin')->name('admin')->middleware(['admincheck'])->group(function (){
 
});

  

  

  

上一篇:Laravel EXCEL存入问题


下一篇:Laravel 表单验证错误返回json格式,重写failedValidation