Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow eager load constraints to still apply for pivot relations. #2

Merged
merged 1 commit into from
May 29, 2019
Merged

Allow eager load constraints to still apply for pivot relations. #2

merged 1 commit into from
May 29, 2019

Conversation

jasonlewis
Copy link

Currently the following won't be constrained:

Plan::with([
    'items.pivot.unit' => function ($query) {
        $query->where('enabled', true);
    }
])->get()

The function is filtered out. This commit preserves the constraining function passed in. Note that I've used ARRAY_FILTER_USE_KEY which was made available in PHP 5.6 so I've bumped the composer.json PHP version as well. Granted, Laravel 5.2 is the oldest version of Laravel that would still work on PHP prior to 5.6.

Cheers.

@ajcastro
Copy link
Owner

Nice. Thanks for this @jasonlewis !

@ajcastro ajcastro merged commit c837a52 into ajcastro:master May 29, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants