Skip to content

Commit

Permalink
Update user retrieval in LocalizationController
Browse files Browse the repository at this point in the history
Altered the user retrieval method in the LocalizationController. It previously used the request's user method directly, albeit it has been updated to employ \App\Models\User::find with the user id returned by the request's method to ensure the correct user is being updated. This will solve potential issues related to the user's locale not updating properly.
  • Loading branch information
Elshaden committed Dec 16, 2023
1 parent c11ce81 commit b67e019
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Http/LocalizationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class LocalizationController extends Controller

public function changeLanguage(Request $request)
{
$User = \App\Models\User::find($request->user()->id);
$User = \App\Models\User::find(auth()->id());

$User->update( ['locale' => $request->language]);

Expand Down
2 changes: 1 addition & 1 deletion src/NovaLocalizationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function bootingPackage()

$language = app()->getLocale() == 'ar' ? 'en' : 'ar';

$menu->prepend(MenuItem::externalLink(app()->getLocale() == 'ar' ? 'English' : 'عربي', '/change-language/' . $language));
$menu->append(MenuItem::externalLink(app()->getLocale() == 'ar' ? 'English' : 'عربي', '/change-language/' . $language));

return $menu;
});
Expand Down

0 comments on commit b67e019

Please sign in to comment.