mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-06 03:02:34 +01:00
f712b789ca
* fix typo * php-cs traits * CS fixer pass * Password protect User routes * Implement checks to prevent editing a deleted record * Clean up payment flows * Fixes for tests
37 lines
875 B
PHP
37 lines
875 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\Language;
|
|
use Closure;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class Locale
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\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);
|
|
}
|
|
}
|