add locale middleware

This commit is contained in:
decoder 2024-03-17 17:40:23 +05:00
parent c5295f0fee
commit 4cb505276f

View File

@ -22,18 +22,14 @@ class LocaleMiddleware
$userSetting = UserSetting::where('user_id', auth()->user()->id)->first();
$locale = 'en';
if (!empty($userSetting)) {
if (!in_array($userSetting->language, ['en', 'ru', 'est'])) {
$locale = $userSetting->language;
}
Session::put('locale', $locale);
app()->setLocale($locale);
if (!empty($userSetting)) {
$userSetting->update([
'language' => $locale
]);
}
Session::put('locale', $locale);
app()->setLocale($locale);
}
return $next($request);