Skip to content

Instantly share code, notes, and snippets.

@franzose
Created March 21, 2014 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franzose/9678204 to your computer and use it in GitHub Desktop.
Save franzose/9678204 to your computer and use it in GitHub Desktop.
Laravel routes and locales made simple (@barryvdh solution)
$languages = array('nl','fr');
$locale = Request::segment(1);
if(in_array($locale, $languages))
{
\App::setLocale($locale);
}
else
{
$locale = null;
}
Route::group(array('prefix' => $locale), function()
{
Route::get('/', array('as' => 'home', function(){ //Do something }));
Route::get('news', array('as' => 'news', 'uses' => 'NewsController@showIndex'));
Route::get('{slug}', 'PageController@showPage');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment