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

[8.x] Add aggregate method to Eloquent passthru #39772

Merged
merged 1 commit into from Nov 25, 2021
Merged

[8.x] Add aggregate method to Eloquent passthru #39772

merged 1 commit into from Nov 25, 2021

Conversation

axlon
Copy link
Contributor

@axlon axlon commented Nov 25, 2021

This PR adds Illuminate\Database\Eloquent\Builder::aggregate(...) to the list of passthru. This allows aggregations that are not included in the eloquent builder by default (e.g. count, min and max) to be used on the eloquent builder without having to call ->toBase() first.

While this is technically breaking, the method is currently unusable so its more of a bugfix. It should not affect anyone as far as I can tell. If you feel it should go to 9.x I'm happy to rebase.

Before:

>>> App\Models\User::query()->aggregate('count', ['*'])
=> Illuminate\Database\Eloquent\Builder {#5256}

After:

>>> App\Models\User::query()->aggregate('count', ['*'])
=> 5927

Edit: I'm also happy to add tests if necessary

@taylorotwell taylorotwell merged commit 097ca1a into laravel:8.x Nov 25, 2021
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

2 participants