laravel / jetstream

Tailwind scaffolding for the Laravel framework.
https://jetstream.laravel.com
MIT License
3.97k stars 822 forks source link

Adding extra middleware #675

Closed anishsarkar closed 3 years ago

anishsarkar commented 3 years ago

Is there any way to add a middleware to any of the routes? For example, I would like to close registration when I reach a count of 10000 users. I was wondering if there is any way other than manually commenting out in the fortify config file the feature of registration.

driesvints commented 3 years ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

joelbutcher commented 3 years ago

@anishsarkar You can add middleware to your fortify config file. Once you've written it, add it to your applications route middleware in app/Http/Kernel.php like so:


    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'foo' => \App\Http\Middleware\FooMiddleware::class,
    ];~~~~

then call it in config/fortify.php using:

    // ...
    'middleware' => ['web', 'foo'],
    // ...