Our Eloquent models have attributes following the Laravel snake case convention.
e.g. first_name
, last_name
and created_at
Although my frontend (react) follows the javascript camel case standard.
e.g. firstName
, lastName
and createdAt
Is there a simple way to convert ALL attributes to camel case when sending an API response?
We are using Larave 5.2 and the Dingo API package.
UPDATE
Following on from the accepted answer I used the Custom Response Format approach. See the following gist for the implementation (includes unit tests):
https://gist.github.com/andrewmclagan/c5e0fe601d23f3b859b89a9f8922be68