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

[11.x] Merge in eager loads from nested where queries #54455

Conversation

ollieread
Copy link
Contributor

This PR merges in any eager loads from nested where clauses, so that withWhereHas can be used within a nested where.

@ollieread ollieread changed the title Merge in eager loads from nested where queries [11.x] Merge in eager loads from nested where queries Feb 3, 2025
@taylorotwell taylorotwell merged commit e4547b4 into laravel:11.x Feb 5, 2025
38 checks passed
@AndreaBellini23
Copy link

AndreaBellini23 commented Feb 21, 2025

After updating to v11.42.0, which implements these changes, a query like

return $query->withWhereHas('model:column', function ($query) {
                            // something ;
                        });

throws a RelationNotFoundException "Call to undefined relationship [model:column] on model [App\Models{model}]
But if I remove the ":column" in withWhereHas, I don't get any exception.

I'm not sure if now this a correct behaviour, so I'm writing this comment before creating an issue.

@ollieread
Copy link
Contributor Author

After updating to v11.42.0, which implements these changes, a query like

return $query->withWhereHas('model:column', function ($query) {
                            // something ;
                        });

throws a RelationNotFoundException "Call to undefined relationship [model:column] on model [App\Models{model}] But if I remove the ":column" in withWhere has, I don't get any exception.

I'm not sure if now this a correct behaviour, so I'm writing this comment before creating an issue.

I'll look into this today for you. It may be worth creating an issue anyway, but link to this PR and tag me in it. I'll see if I can figure out what's happening.

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.

None yet

3 participants