Global Regex Patterns do not work.
Laravel 5.0 documentation states that global patterns should be put on the boot()
function of RouteServiceProvider
.
public function boot(Router $router)
{
parent::boot($router);
$router->pattern(['id' => '[0-9]+']);
}
But they seem to be ignored and thus a GET /test/foo doesn't throw an exception.
It only works if I place it on the route:
Route::get('/test/{id}', function($id) {
return $id;
})->where('id' => '[0-9+]');
UPDATE: I realize I have to register the pattern before the call to the parent's boot.
public function boot(Router $router)
{
$router->pattern(['id' => '[0-9]+']);
parent::boot($router);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community