F
Filament7mo ago
cpbret

Distinct Table Count

Adding distinct() makes it to the count query, but the column does not. Is there a different way? TextColumn::make('responses_count')->counts([ 'responses' => fn ($query) => $query->distinct('request_id') ]) ->label('Responses') SELECT DISTINCT count(*) FROM responses WHERE churches.id = responses.church_id and responses.TYPE = 1) AS responses_count FROM churches
2 Replies
cpbret
cpbretOP7mo ago
Looks like maybe it isn't currently possible
No description
cpbret
cpbretOP7mo ago
Answer: TextColumn::make('responses_count') ->counts([ 'responses' => fn ($query) => $query->select(DB::raw('count(distinct(request_id))')) ])
Want results from more Discord servers?
Add your server