setLocale($locale); $userSetting = UserSetting::where('user_id', auth()->user()->id)->first(); if (!empty($userSetting)) { $userSetting->update([ 'language' => $locale ]); } return redirect()->back(); } }