mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-20 04:24:23 -08:00
e3e0d57f56
* Add IDE Helper files * Cleanup imports - Alphabetises imports - Removes unused imports * Add Platform requirements * Move filling asset into block where asset exists * Remove duplicate array keys
40 lines
1,004 B
PHP
40 lines
1,004 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Models\Setting;
|
|
use Closure;
|
|
|
|
class CheckLocale
|
|
{
|
|
/**
|
|
* Handle the locale for the user, default to settings otherwise.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @param string|null $guard
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next, $guard = null)
|
|
{
|
|
if ($settings = Setting::getSettings()) {
|
|
// User's preference
|
|
if (($request->user()) && ($request->user()->locale)) {
|
|
\App::setLocale($request->user()->locale);
|
|
|
|
// App setting preference
|
|
} elseif ($settings->locale != '') {
|
|
\App::setLocale($settings->locale);
|
|
|
|
// Default app setting
|
|
} else {
|
|
\App::setLocale(config('app.locale'));
|
|
}
|
|
}
|
|
\App::setLocale(config('app.locale'));
|
|
|
|
return $next($request);
|
|
}
|
|
}
|