%PDF- %PDF-
Direktori : /www/loslex/production/app/Http/Middleware/ |
Current File : /www/loslex/production/app/Http/Middleware/Locale.php |
<?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\App; use Symfony\Component\HttpFoundation\Response; class Locale { /** * Handle an incoming request. * * @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next */ public function handle(Request $request, Closure $next): Response { if (Session()->has('locale') AND array_key_exists(Session()->get('locale'), config('app.languages'))) { App::setLocale(Session()->get('locale')); } else { // This is optional as Laravel will automatically set the fallback language if there is none specified App::setLocale(config('app.locale')); } return $next($request); } }