多个中间件到路由

时间:2017-04-10 09:34:25

标签: laravel

我尝试将多个中间件添加到路由中。

像这样:

Route::get('/licences_to_confirm' , ['as' => 'licences_to_confirm', 'uses' => 'LicencieController@licenceToValid'])->middleware( 'isFederation' , 'isComite');

这是我的内核:

'isFederation' => \App\Http\Middleware\isFederation::class,
        'isComite' => \App\Http\Middleware\isComite::class,

这里是我的isFederation Middleware

public function handle($request, Closure $next)
    {
        $user = $request->user();

        if ($user && $user->isFederation())
        {
            return $next($request);
        }
        return redirect(route('403'));
    }

这里是我的isComite中间件:

public function handle($request, Closure $next)
    {
        $user = $request->user();

        if ($user && $user->isComite())
        {
            return $next($request);
        }
        return redirect(route('403'));
    }

但它不起作用。现在有人将多个中间件类添加到路由中吗?非常感谢。

0 个答案:

没有答案