whitecube / nova-page

Static pages content management for Laravel Nova
https://whitecube.github.io/nova-page
MIT License
239 stars 40 forks source link

Automatically load the middleware #6

Closed voidgraphics closed 5 years ago

voidgraphics commented 5 years ago

There is an option to automatically load middleware in Laravel Packages.

It works like this:

// In your package service provider
public function boot()
{
    $router = $this->app['router'];
    $router->pushMiddlewareToGroup('web', MyPackage\Middleware\WebOne::class);
}

Maybe we can load it by default, to make installation easier and quicker, which would be very nice. We can then also make it possible to disable the middleware autoload with a boolean in the config file.

// config/novapage.php
[
    'autoloadMiddleware' => true,
]
toonvandenbos commented 5 years ago

In my opinion we shouldn't autoload the LoadPageForCurrentRoute middleware since most Laravel projects will only need this package on some specific routes. It should be the developer's choice to apply the middleware or not depending his project's requirements.

What if you want autoloading, but not on the "web" middleware group?

Also, the middleware is not the only way to load static content. We should let the developer decide how to load the content knowingly.