Convert response JSON key to camelCase.
In controller class
return response()->json($model);
// => ['userName' => 'foo', 'userKey' => 'bar', ...]
- Laravel 5+
$ composer require 'grohiro/laravel-camelcase-json' '~1.0'
# Laravel 5.7+
$ composer require 'grohiro/laravel-camelcase-json' '~2.0'
Add the service provider.
config/app.php
'provider' => [
// default providers
// ...
Grohiro\LaravelCamelCaseJson\CamelCaseJsonResponseServiceProvider::class,
],