Skip to content

How can map database table fields with data objects ?? #49

Answered by rubenvanassche
Kistlak asked this question in Q&A
Discussion options

You must be logged in to vote

There isn't a proper solution to fix this, in your case, I would create a trait with a method toEloquentAttributes here you can transform a data object toArray and then replace the keys of the array with snakeCase versions of your camelCase keys.

At Spatie we're using snake case properties within our data objects because it clearly communicates to a developer that a property is part of a data object but that's off course personal preference.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kistlak
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