F
Filament2mo ago
kool

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
No description
6 Replies
kool
kool2mo ago
Any ideas why? It seems that the count() when used with groupBy() it returns wrong number.
kool
kool2mo ago
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()); ...
Laracasts
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 ...
kool
kool2mo ago
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
No description
kool
kool2mo ago
@Dan Harrin what do you think about it
Dan Harrin
Dan Harrin2mo ago
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
kool
kool2mo ago
I believe the fix for this specific case is to use getCountForPagination(), it works
$totalRows = $records ? $records->count() : $query->getQuery()->getCountForPagination();
$totalRows = $records ? $records->count() : $query->getQuery()->getCountForPagination();
Thank you for replying back 🙏
Want results from more Discord servers?
Add your server