V
V
Vasyl Fomin2019-07-03 18:48:14
Laravel
Vasyl Fomin, 2019-07-03 18:48:14

Is it possible to use camelCase instead of snake_case in Laravel APIResource and in server requests?

I'm starting to develop an API service on Laravel. The customer asks to use camelCase field names in api json (responses/requests) instead of the standard snake_case!
But the problem is that Laravel uses snake_case as a standard (in pagination fields, database fields, API Resource classes (even if the connection method in the model is written in camelCase - in the response, Resource will turn the field name into snake_case).
In general, is there a possibility without alteration and "shit code" to solve this issue, or will it be correct to use snake_case and convince the customer of this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2019-07-04
@fomvasss

Can. Redefine ->toArray() in the paginator, mb in a few more places and that's enough.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question