Skip to content

What are the implications of overriding the toArray() method on an Eloquent model? #33385

Discussion options

You must be logged in to vote

This has been a monologue but for others stumbling upon my discussion, it seems that there are no adverse implications of toArray(). Basically the only times it seems to be called are when creating a JSON response or when explicitly calling it within your own project code. So I overrode toArray() (instead of my alternative choices like jsonSerialize()) and added image signing, ensuring UTF-8 encoding, and some other things.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by willsmanley
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant