Export Action Only Few Rows with GroupBy
I have a filament resource that displays an order report with native filament export functionality.
The query itself returns 4676 rows but query->count() returns only 4 which limit the results of the exporting
6 Replies
Any ideas why?
It seems that the count() when used with groupBy() it returns wrong number.
I found those:
- https://github.com/laravel/framework/issues/14123
- https://laracasts.com/discuss/channels/eloquent/groupby-count-returns-wrong-value
- https://github.com/laravel/framework/issues/22883
GitHub
Query Builder count() return wrong number with groupBy() · Issue #1...
sorry, my mistake. solved My Laravel version info: Laravel Framework version 5.1.40 (LTS) See this issue #4306 In my test,it's still has problem. dd(Member::groupBy('id')->count()); ...
GitHub
eloquent count() does not work well with groupBy() · Issue #22883 ·...
Eloquent count() completely ignores what is in select and just adds count() as aggregate into select part. If get() method generates this query : select sellers. from sellers left join locations ...
should $query->count get replaced by this?
I tried it and it works but the page is sometimes gives 419 because it exports too many records
@Dan Harrin what do you think about it
I don't have time to help you, but all I will say is that I never intended it to be used with groupby so it was not built to accommodate that being in the query
I believe the fix for this specific case is to use getCountForPagination(), it works
Thank you for replying back 🙏