%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /www/loslex/test/app/Http/Middleware/
Upload File :
Create Path :
Current File : //www/loslex/test/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);    }
}

Zerion Mini Shell 1.0