1 year ago
#312172
Hocine Djouamaa
laravel 7.0 ErrorException Undefined index: user_languages
I am trying to run Laravel 7.0 script
i got this error when i run php artisan serve
ErrorException Undefined index: user_languages
This is the function:
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$locale = 'EN';
if (auth()->check()) {
$user = auth()->user();
$locale = !empty($user->language) ? $user->language : 'EN';
} else {
$checkCookie = Cookie::get('user_locale');
if (!empty($checkCookie)) {
$locale = $checkCookie;
}
}
$generalSettings = getGeneralSettings();
$userLanguages = $generalSettings['user_languages'];
if (!in_array($locale, $userLanguages)) {
$locale = 'EN';
}
\Session::put('locale', mb_strtolower($locale));
return $next($request);
}
}
I cannot make out where the error comes from and I need help.
i'm new in laravel
php
laravel
laravel-7
laravel-middleware
0 Answers
Your Answer