Add user detector#7
Add user detector#7ivanvermeyen merged 4 commits intocodezero-be:masterfrom zepfietje:add-user-detector
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.