Skip to content

Eloquent serialization with hidden (deprecated) attributes #45570

Answered by Kristories
rseon asked this question in Q&A
Discussion options

You must be logged in to vote

It seems like this behavior is intended, as the hidden property only hides attributes from being included in the array representation of the model. The toArray method only checks the hidden property and does not account for custom attribute casting, which is why the exception is thrown in your case.

You could consider using the $appends property instead of custom attribute casting to hide the deprecated name attribute in the serialized representation of your model.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by rseon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants