[5.2] Fix eager loading within global scopes#11779
[5.2] Fix eager loading within global scopes#11779acasar wants to merge 1 commit intolaravel:5.2from acasar:global-scope-relation
Conversation
|
Hmm.. On the second thought I don't know if that's really necessary. I mean we have @joshbodine21 Any particular reason why you want to do it in a global scope? |
|
@acasar In the end, I am trying to use a trait to boot the global scope in more than one model. This is for a REST API and I am filtering the request in some middleware to get the relationships that the user wants to include the endpoint for any given model. I can't use the $with property on the model because I want the user to specify which relationships they want. I just figured what I could do in a local scope I could do in a global one too. Am I looking at this in the wrong way? |
|
Alternative solution that only calls @taylorotwell should I PR that instead? |
|
Submit which ever one you think is best. If you think the other one is better then close this one and submit that one. |
|
Replaced by #11793. |
Fixes #11764
I don't really like that we call
applyScopestwice now (once for query execution and once for eager loading), but since bothgetModels()andeagerLoadRelations()are public, any other solution would be backwards incompatible (we'd need to pass the builder into both methods). I can refactor this for 5.3.