Skip to content

[Feature] Support encoded resource ids #55

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

Merged
merged 5 commits into from
Mar 22, 2021
Merged

[Feature] Support encoded resource ids #55

merged 5 commits into from
Mar 22, 2021

Conversation

lindyhopchris
Copy link
Contributor

This feature adds support for resource ids being encodeable. This allows the developer to encode model ids when serializing to JSON:API resources, and for them to be decoded when parsing resource IDs sent by the client.

To add ID encoding, the ID field must implemented the LaravelJsonApi\Contracts\Schema\IdEncoder interface.

An example use case is needed to hash ids as per #41. As using hashids is a commen use case, we have added the laravel-json-api/hashids package, that adds hashid support via a HashId field class. The dummy application in the tests folder has been updated so that ids are hashed for all test models with integer ids.

Closes #41

@lindyhopchris lindyhopchris merged commit 08c931e into develop Mar 22, 2021
@lindyhopchris lindyhopchris deleted the hashids branch March 22, 2021 14:00
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.

Availability to hash ids
1 participant