jeudi 29 juin 2017

Laravel routing issue for localization

Making a route group for laravel so the url will be www.domain.com/en or www.domain.com/es etc for viewing in a seperate language.

Now when i make the route like so

    Route::group(['prefix' => config('app.locale')], function() {
         Route::get('/', function () {
            return view('pages.home');
         })->name('home');
    });

It throws NotFoundHttpException in RouteCollection.php (line 179) unless it is set to 'en' (the default setting).

However when i hard code it to say 'es' or 'de' it works. But when config('app.locale') is updated to be 'es' or 'de' it throws the error above.

echoing in the view shows the correct values of 'es', 'de' and 'en'

Do i need to enable something or am i doing this wrong?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2trlRqq
via IFTTT

Aucun commentaire:

Enregistrer un commentaire