-
Notifications
You must be signed in to change notification settings - Fork 11.4k
[12.x] Support nested relations on relationLoaded
method
#55595
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
Conversation
93292d1
to
62c803a
Compare
@rodrigopedra @danharrin @tabuna Glad to hear from you on this. |
62c803a
to
05e1edf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that parts of the codebase that were previously using relationLoaded()
now have to use an alternative method indicates that this is a serious enough breaking change that it should not be introduced into the framework, in my opinion.
@danharrin In that point of view you are correct but previously I believe |
I know it doesn't break the places where it is not being called anymore (because you replaced it), but anyone calling this method in a similar way is then going to encounter the new behaviour. |
@danharrin new relationLoaded method also behaves same because it first checks for single level relations, it will switch to new behavior only if $key contains nested relations ('user.posts'). New behavior is also mached 100% to old behavior. I have regression test cases as well to verify the behavior. The places I have replaced the |
Thanks for your pull request to Laravel! Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include. If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions! |
Added support to check nested relations when using
relationLoaded()
method of Eloquent ModelWhy?
Current
relationLoaded()
method only checks single level relation of the Model. Now users can check nested relations.Benefits
End users can check whether the nested relation loaded once and load the desired relation.
About break existing features...
Checked and updated all usage inside the framework and added regressions tests to ensure previous functionality.
Usage of the method outside framework will not break because the feature preserves single level relation check as previously worked.
This is the 2nd attempt of previously reverted #55471
Has added test cases to verify the issues identified previously by @rodrigopedra @danharrin @tabuna.
Related
#55471
#55518
#55519
#55535
dc5b445