laravel middleware only()

Posted 2 months ago by jaheller

Is there a way I can use only in the middleware, when constructing the middleware as array?

Like:

public function __construct(){

    $this->middleware([
        'auth',
        'middleware1',
        'middleware2',
        'middleware3' => [
            'only' => [
                'getMethodName1',
                'getMethodName2',
            ]
        ],
    ]);
}

To assign middleware3 only to the specified methods.

Please sign in or create an account to participate in this conversation.