Custom resource controller actions and more
Pre-release
Pre-release
·
269 commits
to main
since this release
Added
- #12 Can now register routes for custom actions on a resource, using the
actions()
helper method when registering resources. See the PR for examples. - The
JsonApiController
now has the LaravelAuthorizesRequests
,DispatchesJobs
andValidatesRequests
traits applied. - #6 Resource class can now use conditional fields in their relationships. This works in the same way as conditional attributes: the resource's
when()
andmergeWhen()
method should be used to add conditional relationships. - #13 Added French translations for JSON:API errors generated by specification parsing and resource/query parameter validation.
- #7 Eloquent schemas now support default eager loading via their
$with
property. - #15 When parsing a JSON:API document for compliance with the specification, the client will now receive a clearer error message if they submit a to-one relationship object for a to-many relationship (and vice-versa).
Changed
- #2 BREAKING Improved the extraction of existing resource field values when constructing validation data for update requests:
- The
existingAttributes()
andexistingRelationships()
methods on the resource request class has been removed. If you need to modify the existing values before the client values are merged, implement thewithExisting()
method instead. This receives the model and its JSON representation (as an array). - The
mustValidate()
method must now be called on a schema relationship field. (Previously this was on the resource relation.) By default, belongs-to and morph-to relations will be included when extracting existing values; all other relations will not. Use themustValidate()
ornotValidated()
method on the schema relation to alter whether a relation is included in the extracted values.
- The