1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 15:13:29 +01:00
invoiceninja/app/Http/Middleware/Locale.php

37 lines
859 B
PHP
Raw Normal View History

<?php
namespace App\Http\Middleware;
use Closure;
2020-10-28 11:10:49 +01:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Auth;
class Locale
{
/**
* Handle an incoming request.
*
2020-10-28 11:10:49 +01:00
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
/*LOCALE SET */
if ($request->has('lang')) {
$locale = $request->input('lang');
App::setLocale($locale);
} elseif (auth('contact')->user()) {
App::setLocale(auth('contact')->user()->client->locale());
} elseif (auth()->user()) {
App::setLocale(auth()->user()->company()->getLocale());
} else {
App::setLocale(config('ninja.i18n.locale'));
}
return $next($request);
}
}