Search code examples
phplaravellaravel-5routesvoyager

Laravel localization with Voyager admin


I'm making a Laravel website with Voyager admin and now I need to add localization to that website. Voyager includes its own translations table and I'm using it for creating content in multiple languages from backend. But in the frontend routing is not working, I'm getting NotFoundHttpException error. My routes are as following:

Route::group(['prefix' => 'fr'], function()
{
    App::setLocale('fr');
    Route::get('{slug}', 'PageController@show');
    Route::get('posts/{slug}', 'PostsController@show');
    //and so on
});

How can I fix this?


Solution

  • According to the documentation you can go

    Route::prefix('admin')->group so

    Route::prefix('fr')->group(function()
    {
        App::setLocale('fr');
        Route::get('{slug}', 'PageController@show');
        Route::get('posts/{slug}', 'PostsController@show');
        //and so on
    });
    

    AND also the order is important.