Change plural to singular in getInverseRelationship in HasQuery #14145
+14
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.