Routes
Modules should not define routes, boxes are expected to. An App may or may not want to use routes provided by a box. Registering of routes therefore can be enabled in the box config very similarly to views.
return [
'modules' => [
Vendor\MyBox\Providers\BoxServiceProvider::class => [
'routes' => [
'files'=> ['web', 'api']
], // register specific routes
'routes' => true, // register all routes in the folder (*.php)
'routes' => false // don't register any routes
]
]
];
All routes will be included in a route group whose parameters can also be configured:
return [
'modules' => [
Vendor\MyBox\Providers\BoxServiceProvider::class => [
'routes' => [
'files' => ['web', 'api'],
'namespace' => 'Name\\Space\\Here', // Defaults to the module's route namespace
'prefix' => 'url_prefix', // Defaults to the module's short name
'as' => 'route.prefix.', // default is module's short name and a dot ('.') at the end
'middleware'=> ['web', 'auth', 'acl'] // defaults to ['web']
]
]
]
];
Multiple Route Groups
To register routes with different settings (v1.3+):
return [
'modules' => [
Vendor\MyBox\Providers\BoxServiceProvider::class => [
'routes' => [
[
'files' => ['acl'],
'prefix' => '/admin',
'as' => 'admin.',
'middleware'=> ['web', 'auth', 'acl']
],
[
'files' => ['nonacl'],
'prefix' => '/admin',
'as' => 'admin.',
'middleware'=> ['web', 'auth']
]
]
]
]
];
Route Model Bindings
Up until Concord v1.6, all the models that were registered with Concord were automatically bound to
the Laravel router by implicitly calling the Route::model()
method.
See: https://laravel.com/docs/7.x/routing#route-model-binding
Eg. if your module defines a Product
model, then Concord calls Route::model('product', Product::class)
upon registering the model.
As of v1.7.0 this behavior can be disabled, by setting the register_route_models
configuration to
false in your app's config/concord.php
file:
// config/concord.php
return [
'register_route_models' => false,
'modules' => [
// list of modules here...
]
];
This will prevent Concord from automatically registering models with the router.
Next: Resources »