V
V
Vatrush2019-05-21 16:28:41
Laravel
Vatrush, 2019-05-21 16:28:41

Why is the broker group not working?

Here are the routes I try, but for some reason they do not work.
In a group:

Route::group(['middleware' => ['verification']], function (){
  //
});

Separately listed:
Route::group(['middleware' => ['first','second']], function (){
  //
});

If you create a route with only one intermediary first or second, then everything works fine.
Here is my Kernel:
protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],

        'verification' => [
            'first',
            'second',
        ],

    ];
 protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
        'first' => \App\Http\Middleware\RedirectIfFirst::class,
        'second' => \App\Http\Middleware\RedirectIfSecond::class,

    ];

If I follow the desired route by calling 2 intermediaries or a group at once, then they won’t let me in, but if I use intermediaries separately from each other, then everything is fine

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FreeZOn, 2019-05-22
@FreeZOn

In the package itself, the middleware group is called a little differently: Route::middleware('web')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question