【问题标题】:More than only one methods to authentication middleware on laravel在 laravel 上验证中间件的方法不止一种
【发布时间】:2016-01-30 15:38:11
【问题描述】:

我在我的 laravel 项目中有这个,我想向 exept 数组添加更多方法。我不知道该怎么写?

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

    }

【问题讨论】:

标签: php laravel-5 middleware


【解决方案1】:

只需添加这样的数组:

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

    }

您可以在此处查看更多信息:https://laravel.com/docs/5.1/controllers#controller-middleware

【讨论】:

  • 非常感谢!我不明白我怎么会这么笨,除了这个我什么都试过了。
【解决方案2】:

试试这个

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

}

【讨论】:

    猜你喜欢
    • 2021-12-05
    • 1970-01-01
    • 1970-01-01
    • 2014-09-04
    • 2018-01-29
    • 2017-10-07
    • 1970-01-01
    • 2018-10-12
    • 2013-11-23
    相关资源
    最近更新 更多