Is there an easy way to not return guarded properties for an eloquent model?
I want to return a User and build a similar User object on the front end. However, I don't want to return the Users password, type_id, remember_token and other properties. Is there a simple way I can restrict the application from returning these properties? I'm aware I can a write a method or attribute that returns only the values I want, but I'm wondering if there's an unguarded() function for eloquent or collections.
If not, how would you recommend doing this. I'd probably scope it as opposed to wrting an attribute, mutator or method.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Ki7GrH
via IFTTT
Aucun commentaire:
Enregistrer un commentaire