mcamara / laravel-localization

Easy localization for Laravel
MIT License
3.36k stars 512 forks source link

got 404 not found after using php artisan route:trans:cache #904

Closed mgaber2024 closed 2 months ago

mgaber2024 commented 4 months ago

Describe the bug I got 404 after I used php artisan route:trans:cache command and added
use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes; in route service provider as described in the docs

Expected behavior I should can access the app routes normally

More info:

`

tringuyenduc2903 commented 4 months ago

Two ways to solve this problem https://github.com/mcamara/laravel-localization/issues/899#issuecomment-2096959567

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

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

(or)

https://github.com/mcamara/laravel-localization?tab=readme-ov-file#caching-routes

<?php
class RouteServiceProvider extends ServiceProvider
{
    use \Mcamara\LaravelLocalization\Traits\LoadsTranslatedCachedRoutes;
MilanUnjiya4149 commented 3 months ago
RouteServiceProvider::loadCachedRoutesUsing(fn() => $this->loadCachedRoutes());

This solution is working.

@tringuyenduc2903 Thank You ☺