A multi-word name, such as the creation date, can be written three ways in the document. The package converts for you; in your code you always write snake_case.
The three styles
The member_case option (variable JSON_, default camel) decides how multi-word names are written in the document:
| Value | How created_at is written | Sort example |
|---|---|---|
camel | createdAt | sort=-createdAt |
kebab | created-at | sort=-created-at |
snake | created_at | sort=-created_at |
The JSON:API 1.1 specification recommends camelCase for member names, which is why it is the default. kebab and snake are your choice, and the package supports them just the same.
What changes and what does not
The style applies, on input and output, to:
- attributes and relationships;
- the
sortandfieldsparameters; - the pagination
meta(for examplecurrent-pagewithkebab).
Types, ids, links and error pointers do not change with the style.
In your code
You always write snake_case, as in Eloquent: 'created_at' => $this->created_at in the resource, jsonApiSort(['created_at']) in the controller. The package converts the name to the configured style when it responds, and the one that comes from the client to snake_case when it reads it. If you change the style, your code does not change.
JSON_API_MEMBER_CASE=kebab