perhaps if you have a frontend that gets translation from backend for content areas? or when the api needs to returns localized error messages?
Right, updating the accepted answer to clarify this for posterity.
@36864 the reason i added it to $routeMiddleware is because the documentation on default values has example on {locale} and tells you to add it to $routeMiddleware.
https://laravel.com/docs/5.5/urls#default-values
and links to: https://laravel.com/docs/5.5/middleware#assigning-middleware-to-routes
Maybe it would make sense to raise an issue over at github for this then, either a documentation change is in order or the way defaults are set needs to change, or the way redirects are handled in the auth middleware needs to change.
done
We can make dynamic route by this way
// Instanciate a router class.
$router = app()->make('router');
Get Route value from Database
// For route path this can come from your database.
$paths = ['path_one','path_two','path_three'];
Then iterate the value to make dynamic route
// Then iterate the router "get" method.
foreach($paths as $path) {
$router->resource($path, 'YourController');
}
You can use GET|POST|PUT|PATCH|DELETE methods also
// Then iterate the router "get" method.
foreach($paths as $path) {
$router->get($path, 'YourController@index')->name('yours.index');
}
@pawanyd Post is 2 years old...
Please or to participate in this conversation.