Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hyphen as default for member names when converting Eloquent attributes #17

Closed
lindyhopchris opened this issue Aug 26, 2016 · 1 comment
Milestone

Comments

@lindyhopchris
Copy link
Member

The JSON API spec recommends that member names use the lower case characters a-z and the hyphen - as the only allowed characters for member names. This is also the default being adopted by other libraries that implement the spec, e.g. Ember Data.

The recommendation is made here:
http://jsonapi.org/recommendations/#naming

Make this the default implementation for this library, by changing EloquentSchema::keyForAttribute() and AbstractSortedSearch::columnForField() methods.

Applications not following this recommendation can keep the old behaviour by overloading these methods.

@lindyhopchris lindyhopchris added this to the 0.5.0 milestone Aug 26, 2016
lindyhopchris added a commit that referenced this issue Sep 1, 2016
The JSON API spec recommends using hyphenated member names. This
package now follows that recommendation by default.

The Eloquent schema will dasherize model keys, so `foo_bar` will
become `foo-bar`. This behaviour can be turned off or overloaded
as required.

The abstract search will snake case sort parameters if the model
uses snake cased attributes. If the model does not use snake case,
it will came case the search field instead. The behaviour can
be changed by overloaded as required.

See issue #17
@lindyhopchris
Copy link
Member Author

Closing as this is available via Componser on the v0.5.x-dev release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant