mcamara / laravel-localization

Easy localization for Laravel
MIT License
3.32k stars 507 forks source link

localization route not working after php artisan route:cache I get 404 #893

Closed MilanUnjiya4149 closed 5 days ago

MilanUnjiya4149 commented 4 months ago

localization route not working after php artisan route:cache. It's return 404. It's work perfect without route cache.

  1. Create route in web.php Route::group( [ 'prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localize'] ], function () { Route::get('/', 'HomeController@index')->name('index'); } );
    1. php artisan route:cache

Localization route should work after php artisan config:cache

juliangarcess commented 4 months ago

Please read the docs about CACHING

ianfortier commented 4 months ago

@juliangarcess The caching (artisan route:trans:cache) doesn't work either

juliangarcess commented 4 months ago

did you run artisan route:clear?

MilanUnjiya4149 commented 5 days ago

904

`class AppServiceProvider extends ServiceProvider { use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;

public function boot(): void
{
    RouteServiceProvider::loadCachedRoutesUsing(fn() => $this->loadCachedRoutes());
    ...
}`

This solution is working fine. ☺