1

after grouping urls with prefix in web.php I have created language switcher like this

Route::redirect('/','/ge');
Route::group(['prefix' => '{language}'],function (){
    Route::get('/', function () {
        return view('welcome');
    });
});

I tested it and it was working fine. now I need to add links ( language switcher) but after I do this I receive an exception and an error.

Symfony\Component\Routing\Exception\RouteNotFoundException
Route [] not defined. (View: /Users/mac/laravel/Template/resources/views/welcome.blade.php)
        throw new RouteNotFoundException("Route [{$name}] not defined.");

my list looks like that

 <div class="languages">
            <ul>
                <li><a href="{{route(\Illuminate\Support\Facades\Route::getCurrentRoute(),'ge')}}">GE</a></li>
                <li><a href="{{route(\Illuminate\Support\Facades\Route::getCurrentRoute(),'en')}}">EN</a></li>
                <li><a href="{{route(\Illuminate\Support\Facades\Route::getCurrentRoute(),'ru')}}">RU </a></li>
            </ul>
        </div>

I even used \Illuminate\Support\Facades\Request::route()->getName() instead of route(\Illuminate\Support\Facades\Route::getCurrentRoute() but looks like problem is something different. Route::currentRouteName() is not working as well

Giga Todadze
  • 63
  • 1
  • 11

1 Answers1

1

I have found a fix here https://spacecode.dev/post/route-route-name-not-defined-solve-the-problem run commands

php artisan route:clear
php artisan route:cache

will fix that.

Giga Todadze
  • 63
  • 1
  • 11