123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Http\Middleware;
- use Closure;
- use App;
- use Session;
- use Config;
- class Language
- {
- /**
- * Handle an incoming request.
- *
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @return mixed
- */
- public function handle($request, Closure $next)
- {
- if(Session::has('locale')){
- $locale = Session::get('locale');
- }
- else{
- $locale = env('DEFAULT_LANGUAGE','en');
- }
- App::setLocale($locale);
- $request->session()->put('locale', $locale);
- return $next($request);
- }
- }
|