For example, I have defined routes like this:
$locale = Request::segment(1);
Route::group(array('prefix' => $locale), function()
{
Route::get('/about', ['as' => 'about', 'uses' => 'aboutController@index']);
}
I want to generate links for several locales (en, de, es,...). When I try to provide prefix parameter like this
$link = route('about',['prefix' => 'de']);
I got link like this example.com/en/about?prefix=de
How to provide prefix param to got link like this example.com/de/about
You can play around with something like this perhaps.
Route::group(['prefix' => '{locale}'], function () {
Route::get('about', ['as' => 'about', 'uses' => '....']);
});
route('about', 'en'); // http://yoursite/en/about
route('about', 'de'); // http://yoursite/de/about
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With