阅读(3123) (0)

Laravel 项目开发规范 中间件

2023-01-30 16:56:30 更新

Auth 中间件

Auth 中间件 必须 书写在控制器的 __construct 方法中,并且 必须 使用 except 黑名单进行过滤,这样当你新增控制器方法时,默认是安全的。

public function __construct()
{
    $this->middleware('auth', [            
        'except' => ['show', 'index']
    ]);
}