Auth 中间件

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

  1. public function __construct()
  2. {
  3. $this->middleware('auth', [
  4. 'except' => ['show', 'index']
  5. ]);
  6. }