Skip to content

Conversation

@lindyhopchris
Copy link
Contributor

Resource classes are now optional. If one does not exist, the implementation falls-back to serializing resource using the schema. The serialization can be customised on the Eloquent schema using the hidden() and serializeUsing() methods.

The change also updates the JsonApiResource method signatures for the attributes, relationships, meta, and links methods so that they receive the HTTP request as the first (and only) parameter. This brings the implementation in line with Laravel's Eloquent resources, which receive the request to their toArray() method. The slight difference is our implementation allows the request to be null - this is to cover encoding resources outside of HTTP requests, e.g. queued broadcasting.

This is a breaking change. Any existing Resource classes will either need to be deleted, or if keeping them the method signatures for the attributes, relationships, links and meta methods need to be updated to add the request as the first parameter.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants