-
-
Notifications
You must be signed in to change notification settings - Fork 97
Transformation
This boilerplate contains a very rich transformation layer, containing a lot of useful functionality.
All relations which have been loaded in the model(s) which are being transformed for response, themselves will get transformed using their own transformers. This works recursively. All related models will appear as nested objects in the response.
One of the features of this boilerplate is to allow for configuring which case type you would like in your responses. Currently the options "camel-case" and "snake-case" are supported.
You can change this setting in your config/api.php file, the setting is under the name "formatsOptions.caseType".
This boilerplate also accepts a special header named "X-Accept-Case-Type", which will override any configuration (as specified above) and allow the request caller to specify the case type they would prefer.
This is especially useful if you have multiple API consumers, and they have different preferences for case type.
PHP Guzzle Example:
$api->get('http://your-api.com/resource', [
'headers' => ['X-Accept-Case-Type' => 'snake-case'],
]);