-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Change plural to singular in getInverseRelationship in HasQuery #14145
base: 3.x
Are you sure you want to change the base?
Conversation
Hi @pelmered are you still planning to work on this? |
Sorry, I have been really busy the last few weeks. And I will probably be busy for the next few weeks as well. |
No worries, @pelmered! Ready for merge! 😊🚀 |
Great! Thank you! 😁🚀 |
Description
This fixes #14090 where the inverse of a one to many-relationship in the
AssociateAction
uses plural for the relation name and subsequently also the foreign key. This is according to the Laravel convention.Visual changes
N/a
Functional changes
AssociateAction
Looking at the Laravel documentation as an example: https://laravel.com/docs/11.x/eloquent-relationships#one-to-many-inverse.
On the post resource we add a relationship manager for comments, and in the relationship manager we add an
AssociateAction
to associate comments with the current post.The current code would look for the inverse relationship with the name
posts
(plural) instead ofpost
(singular).This is only tested for one to many-relationships and many to many-relationships. The
$relationship instanceof HasMany
if-statement probably needs to be updated to cover more cases.