I'm using Laravel locale, need to show language sign at the URL, I created a route group like so, and listed my routes inside the group
Route::group(['prefix' => App::getLocale()], function(){
Route::get('login','Hostato\Admin\Controllers\Auth\LoginController@showLoginForm')
->name('login');
});
but it always show 'localhost:8000/en/logoin', although if i render at the view
{{ App::getLocale() }}
it shows the correct chosen language sign
at the route group prefix do i need to use another way rather than ?
App::getLocale()
You should use parameter instead of hardcoding the setLocale()
method call:
Route::group(['prefix' => '{lang}'], function() {
And then in middleware set locale:
public function handle($request, Closure $next)
{
app()->setLocale($request->lang);
return $next($request);
}