Skip to content

Add support for eager loading specific columns to withWhereHas#45168

Merged
taylorotwell merged 2 commits into
laravel:9.xfrom
diaafares:improve-withWhereHas
Dec 2, 2022
Merged

Add support for eager loading specific columns to withWhereHas#45168
taylorotwell merged 2 commits into
laravel:9.xfrom
diaafares:improve-withWhereHas

Conversation

@diaafares

Copy link
Copy Markdown
Contributor

Hi,
withWhereHas() didn't work as expected when I tried to eager load specific columns the same way that we are doing using with('user:id,first_name,last_name') and it gave me the following error:
Call to undefined method Employee::user:id,first_name,last_name()

This PR adds support for eager loading specific columns to withWhereHas(), so it is now consistent with with() method and works as expected:
withWhereHas('user:id,first_name,last_name')

Please let me know if anything is needed ☺️

@taylorotwell taylorotwell merged commit d961975 into laravel:9.x Dec 2, 2022
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