-   Notifications  
You must be signed in to change notification settings  - Fork 11.6k
 
Closed
Labels
Description
Laravel Version
10.45.1
PHP Version
8.1.27
Database Driver & Version
No response
Description
The getPrefix() method of the Illuminate\Routing\Route returns different values for non-cached and cached routes:
/{locale}- the return value of the getPrefix() method for a non-cached route{locale}- the return value of the getPrefix() method for a cached route
This discrepancy in the results for non-cached/cached routes seems a sort of bug to me.
This issue might be related with #43882 and #43997.
Steps To Reproduce
After installing a new Laravel project, just add a route group to the web routes (the /routes/web.php file). For example:
Route::group([ 'prefix' => '{locale}', 'where' => ['locale' => 'en|fr|de'], ], function () { Route::get('/', function () { return view('welcome'); }); });Then, use the tinker tool to get the registered routes and check the getPrefix() return values.
 Let's check the non-cacned routes:
$routes = app('router')->getRoutes()->get('GET'); foreach ($routes as $route) { dump($route->getPrefix()); }Then, we can cache the routes with artisan route:cache command and use tinker again.
$routes = app('router')->getRoutes()->get('GET'); foreach ($routes as $route) { dump($route->getPrefix()); }
