Skip to content

Instantly share code, notes, and snippets.

@Anderson-Juhasc
Last active April 11, 2016 18:20
Show Gist options
  • Save Anderson-Juhasc/b687e44ca2f7b464b0e9f84351f57abc to your computer and use it in GitHub Desktop.
Save Anderson-Juhasc/b687e44ca2f7b464b0e9f84351f57abc to your computer and use it in GitHub Desktop.
<?php
$country = Request::segment(1);
$locale = Request::segment(2);
if (Schema::hasTable('countries')) {
$Country = \App\Countries::where('name_iso3166', $country)->get();
if (count($Country)) {
$available_lang = explode(',', $Country[0]['available_languages']);
} else {
$available_lang = Config::get('app.available_lang');
}
if (in_array($country, Config::get('app.available_countries')) && in_array($locale, $available_lang)) {
\App::setLocale($locale);
} else {
$country = null;
$locale = null;
}
}
Route::group(['middleware' => 'web', 'prefix' => "$country/$locale"], function () {
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment