[5.5] Fix getQualifiedParentKey on BelongsToMany #21128
Merged
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.
This is a continuation of the fixes from #21044
Example Code:
The services belongsToMany relation has a parentKey specified as
user_id
, the below SQL query shows that it still wants to use user_temporary_profiles.id
as opposed to user_temporary_profiles.user_id
Without this fix, queries using any of the has methods will return incorrect results as the query is trying to make use of the default getQualifiedKeyName on the parent (See https://github.com/laravel/framework/blob/5.5/src/Illuminate/Database/Eloquent/Relations/Relation.php#L262)