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

Hydrate has-many in Eloquent Hydrator #29

Closed
lindyhopchris opened this issue Nov 17, 2016 · 2 comments
Closed

Hydrate has-many in Eloquent Hydrator #29

lindyhopchris opened this issue Nov 17, 2016 · 2 comments
Labels
Milestone

Comments

@lindyhopchris
Copy link
Member

This line:
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Hydrator/EloquentHydrator.php#L160

Does not work, because on a create request the model does not yet have a key (as it has not been saved at this point).

I suspect this line is not meant to be in here, because hydration of a has-many relationship actually happens here:
https://github.com/cloudcreativity/laravel-json-api/blob/master/src/Hydrator/EloquentHydrator.php#L187

@lindyhopchris lindyhopchris added this to the 0.6.0 milestone Nov 17, 2016
@lindyhopchris
Copy link
Member Author

It's probably in there because if hydrating a relationship on a relationship endpoint, it would need to sync the relationship. However things are starting to get confusing as to what should be hydrated where.

Probably need to make it that has-many relationships are always hydrated in related methods rather than relationship methods. So when support for relationship endpoints is properly added, the Eloquent controller would always expect to call hydrateRelatedTags rather than hydrateTagsRelationship.

@lindyhopchris
Copy link
Member Author

This is now working on the 1.x-dev branch, with relationship hydration handled by resource/relationship adapters.

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

No branches or pull requests

1 participant