-
Notifications
You must be signed in to change notification settings - Fork 11.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature]: Adding Callback to Set Locale #52330
[Feature]: Adding Callback to Set Locale #52330
Conversation
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
You can use withLocale for a single-use only or useLocale: Number::useLocale(Auth::user()?->locale ?? config('app.locale')); |
This doesn't work because Auth::user() in this case will always be null within the AppServiceProvider. |
Have you tried using middleware? Setting this at the service provider is more logical for situations where the locale comes from a config rather than the user. Furthermore, your PR breaks principles by using the |
Why would I make middleware, when I can define a callback in my service provider, just like Laravel uses in other resources? https://laravel.com/docs/11.x/passwords#reset-link-customization It's a feature that I find interesting. |
I mentioned the middleware thinking about getting the current authenticated user, that doesn't exist in the service provider layer. |
I want to add the locale dynamically within the Number class.
Example: