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

[5.7] Fix wrong class being used when eager loading nullable MorphTo with withDefault() #27382

Closed
wants to merge 1 commit into from

Conversation

bucaneer
Copy link
Contributor

@bucaneer bucaneer commented Feb 1, 2019

Fixes #27369

Currently, MorphTo inherits the newRelatedInstanceFor() method from BelongsTo, which ignores the passed $parent argument and instantiates a related model based on the generalized relationship instance (without constraints) produced by the query builder . However, in the case of MorphTo relations, the no-constraint relationship instance does not know anything about related classes, and wrongly defaults to the parent model class. This commit simply makes use of the $parent argument to produce a related instance that is appropriate for the parent model instance.

@taylorotwell
Copy link
Member

I am closing this pull request because it lacks sufficient tests. It is difficult for us to merge pull requests without these things because the change may introduce breaking changes to the framework.

Feel free to re-submit your change with a thorough explanation of the feature and tests - integration tests are preferred over unit tests.

Thanks!

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