Glad it's not just me.
Since L5.3 you can split your routes into files. Since then I have separate route files relating to things like the auth levels and areas of the site. E.g
web.php //public routes
customer.php //customer login
admin.php // staff login
These are mapped in the RouteServiceProvider.php
public function map()
{
$this->mapWebRoutes();
$this->mapCustomerRoutes();
$this->mapAdminRoutes();
}
// then subsequently you can also add in things like a prefix to apply to all the routes in each file:
protected function mapCustomerRoutes()
{
Route::group([
'middleware' => 'web',
'prefix' => 'customer',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/customer.php');
});
}
It also makes it very clear and easy to do things like apply middleware and pass parameter to a set of routes e.g.
protected function mapAdminRoutes()
{
Route::group([
// pass admin param to role middleware to check admin privileges
'middleware' => ['web', 'role:admin' ],
'prefix' => 'admin',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/admin.php');
});
}