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')

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
Was this page helpful?