I'm building a multilingual Website using Laravel but I'm facing a problem about Locales.
I have 2 Languages for now (Ar/En) and my routes accept prefix to determine the Language.
I want my routes to be valid if not having a prefix and set a default Locale.
my current code is :
Route::group([
'prefix' => '/{locale?}',
'where' => ['locale' => '^(ar|en)$'],
'middleware' => ['setLocale']
], function(){
Route::get('/', function () {
return view('home');
});
Route::get('test', function (){
return 'test';
});
});
It works for the first route but for any sub-routes its not working if prefix is not provided!