-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Make it possible to hide some attributes for serialization #112
Comments
Hi @mgiritli, You’re right — this feature isn’t built in right now, you’ll have to do it manually. Though it should definitely be included. Give me a day or two and I’ll have this patched in, thanks for letting me know! |
Full credit again to @taylorotwell and the Laravel framework: https://ldaprecord.com/docs/credits/ - DirectoryTree/LdapRecord-Laravel#112
🎉 All done. You can now add Via Properties: class User extends Model
{
protected $hidden = ['userPassword'];
} Via Methods: $user = User::findByAnr('steve');
$user->addHidden('userPassword');
// Or:
$user->makeHidden('userPassword');
// 'userPassword' will be removed from the encoded array.
json_encode($user); A new release will be out in a couple hours 😄 |
This has now been released in v1.4.0. |
Thanks so much, Steve :-) |
Glad to help @mgiritli! Please feel free to drop in anytime you have any suggestions 😄 |
Similar to the possibility which exists with Eloquent models, I think it should be possible to hide some attributes for serialization purposes. For example, I currently serialize models for logging purposes and don't really want userPassword attribute to be included.
Is this possible?
The text was updated successfully, but these errors were encountered: