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

Add support for custom too many relations #30

Merged
merged 4 commits into from
Oct 29, 2023

Conversation

genyded
Copy link
Contributor

@genyded genyded commented Oct 25, 2023

We need support for custom relations like https://github.com/culturegr/custom-relation. However Laravel JSONAPI is restricted to the default types (HasMany, etc). This simple change allows our needed custom 'too many' relation to work in Laravel JSONAPI and does not seem to have any side effects. We hope it can be integrated or an alternative added so that we can continue using the library.

Copy link
Contributor

@lindyhopchris lindyhopchris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thanks for raising, and yes I'm open to changing this. See my comment on the PR - hopefully it makes sense as to how to modify the PR along the lines I'm suggesting? Just ask questions if it doesn't make sense.

src/QueryToMany.php Outdated Show resolved Hide resolved
relations as well as adding support for custom
for custom too one relations
@genyded
Copy link
Contributor Author

genyded commented Oct 29, 2023

We're very grateful that we've been able to make Laravel JSONAPI meet our needs thus far and find it to be an awesome implementation! I also realize this is not the 'day' job. That said, I'll sleep better at night once this is tagged, as we are on a tight timeline.

@lindyhopchris
Copy link
Contributor

No worries, just looking at it now!

@lindyhopchris
Copy link
Contributor

@genyded quick question for you - how are you using this with the custom relation package? That package seems to be on Laravel 9, but this package is on Laravel 10?

@lindyhopchris lindyhopchris merged commit 3daaf05 into laravel-json-api:develop Oct 29, 2023
2 checks passed
@lindyhopchris
Copy link
Contributor

Tagged as v3.1.0 which is for Laravel 10.

I'd prefer not to have to backport this to Laravel 9, but let me know how you're currently using the custom relations package.

@genyded
Copy link
Contributor Author

genyded commented Oct 29, 2023 via email

@lindyhopchris
Copy link
Contributor

Any plans to release your own implementation? I actually think it'd be really useful to link to from the Laravel JSON:API docs if you were going to open source it, as it would allow people to do more complex relations on their models, which they can then use for JSON:API.

@genyded
Copy link
Contributor Author

genyded commented Oct 29, 2023 via email

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