小结
流程图
关键代码
-
1 创建中间件
make artisan make:middleware EmailVerified
-
2 编写中间件
public function handle($request, Closure $next) { }
-
3 在 Kernal 文件中注册中间件
'email_verified' => \App\Http\Middleware\CheckIfEmailVerified::class,
-4使用中间件
Route(['middleware' => 'email_verified'],function() {
/// 需要中间件校验的路由
});
Tip
推荐文章: