-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add user detector #7
Conversation
Thanks for your contribution! Before merging I'd like to make sure we support this Laravel feature: Perhaps the attribute can be null by default? |
Hmm I'm not sure how we should handle that. |
I was thinking if this is null in the config by default:
Then we can check for it to avoid the MissingAttributeException: if ($attribute === null || $user === null) {
return null;
} |
Isn't it clearer then to not include the detector in the default array? |
Yeah, I understand. Another option is perhaps to check if the attribute exists? |
Unfortunately Laravel has no if ( ! in_array($attribute, $user->getAttributes())) {
return null;
} |
Yeah that should work. |
@ivanvermeyen, we might use Just tested, it should work. |
This PR should be ready now, @ivanvermeyen. |
I'm not sure how big of an impact this has on performance, like you stated. |
Casting only seems to happen for the specific attribute you're accessing. Edit: actually casting does happen for all attributes I think. |
Okay, this isn't any less performant than magically accessing properties like |
Great, thanks for putting this together 👍 |
Thanks a lot for being so swift and maintaining these awesome packages! |
This PR adds a detector to get the locale from the currently authenticated user, if any.