© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Fasna

Aggregated Table with Bulk Action

I have a table with aggregated columns, I use the row number() as id.
fn() => Opportunity::select('seller')
                    ->selectRaw("ROW_NUMBER() OVER (ORDER BY COUNT(CASE WHEN asset_class = 'Aircraft' THEN 1 END)) AS id")
                    ->selectRaw("COUNT(CASE WHEN asset_class = 'Aircraft' THEN 1 END) AS aircraft_count")
                    ->selectRaw("COUNT(CASE WHEN asset_class = 'Engine' THEN 1 END) AS engine_count")
                    ->selectRaw("COUNT(CASE WHEN asset_class = 'Ship' THEN 1 END) AS ship_count")
                    ->selectRaw("COUNT(CASE WHEN asset_class = '' THEN 1 END) AS other_count")
                    ->where('deal_stage', '!=', '00. Training')
                    ->groupBy('seller')
                    ->orderBy('aircraft_count', 'desc')
fn() => Opportunity::select('seller')
                    ->selectRaw("ROW_NUMBER() OVER (ORDER BY COUNT(CASE WHEN asset_class = 'Aircraft' THEN 1 END)) AS id")
                    ->selectRaw("COUNT(CASE WHEN asset_class = 'Aircraft' THEN 1 END) AS aircraft_count")
                    ->selectRaw("COUNT(CASE WHEN asset_class = 'Engine' THEN 1 END) AS engine_count")
                    ->selectRaw("COUNT(CASE WHEN asset_class = 'Ship' THEN 1 END) AS ship_count")
                    ->selectRaw("COUNT(CASE WHEN asset_class = '' THEN 1 END) AS other_count")
                    ->where('deal_stage', '!=', '00. Training')
                    ->groupBy('seller')
                    ->orderBy('aircraft_count', 'desc')

Now, when I select the records for bulk action, the Collection $records variable is holding different values than what I have selected. Could anyone tell me how to get the correct values that I selected.
image.png
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Table Bulk Action
FilamentFFilament / ❓┊help
3y ago
Table Performance - Bulk Actions
FilamentFFilament / ❓┊help
2y ago
bulk action
FilamentFFilament / ❓┊help
3y ago
Bulk Action
FilamentFFilament / ❓┊help
3y ago