HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Http/Middleware/Languages.php
<?php

namespace App\Http\Middleware;

use App\Komma\Languages\Models\Language;

final class Languages
{
    /**
     * Handle an incoming request.
     *
     * @param \Illuminate\Http\Request $request
     * @param \Closure $next
     * @return mixed
     */
    public function handle($request, \Closure $next)
    {
        //Check if application is defined for multiple applications
        if (\Config::get('app.multipleLanguages')) {
            //Check for language cookie
            $languageIso = \Cookie::get('language', false);

            // Check if there isn't a cookie defined
            // Then check for language session
            if ($languageIso == false) {
                $languageIso = \Session::get('language', false);
            }

            // Now check if the language iso isset
            //so basically if it is an active visitor (or a return visitor by cookie)
            if ($languageIso == false) {
                //Grab the default language
                $languageIso = \App::getLocale();
            }
        } else {
            //If not multiple language
            //Grab the default language defined in App config
            $languageIso = \App::getLocale();
        }

        // When using the KMS overwrite the site/cookie setLocale by the kms config locale
        if ($request->segment(1) == 'kms') {
            $languageIso = config('kms.main.locale');
        }

        // Get Language model and set to Application
        $language = Language::where('iso_2', $languageIso)->first();
        \App::setLanguage($language);

        return $next($request);
    }
}