Created
May 21, 2015 12:04
-
-
Save sleeping-owl/7ccb20cb3fc1f2494911 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace App\Http\Middleware; | |
use Closure; | |
use Config; | |
use Illuminate\Http\Request; | |
use Session; | |
class AdminLocale | |
{ | |
public function handle(Request $request, Closure $next) | |
{ | |
if (($request->getHost() == getenv('APP_DOMAIN')) && preg_match('/\/admin/', $request->url())) | |
{ | |
if ( ! Session::has('admin.locale')) | |
{ | |
$locales = Config::get('translatable.locales'); | |
Session::put('admin.locale', $request->getPreferredLanguage($locales)); | |
} | |
app()->setLocale(Session::get('admin.locale')); | |
} | |
return $next($request); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment