Route::get('user/{id}/{name}/{age?}', function ($id, $name, $age = 'noage') { return 'User '.$id.' '.$name.' '.$age; }); Trying to set a global limit for id in RouteServiceProvider.php Now it has the following content:
public function boot() { $this->setRootControllerNamespace(); if ($this->app->routesAreCached()) { $this->loadCachedRoutes(); } else { $this->loadRoutes(); $this->app->booted(function () { $this->app['router']->getRoutes()->refreshNameLookups(); $this->app['router']->getRoutes()->refreshActionLookups(); }); } } I can’t add Route::pattern('id', '[0-9]+') (as in the documentation), it gives the error Class 'Illuminate\Foundation\Support\Providers\Route' not found
What am I doing wrong? Version 5.5.58
\Route::pattern('id', '[0-9]+')- P. Fateev