© 2026 Hedgehog Software, LLC

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

Count same relationship in multiple columns

I want to have some columns counting the same relationship, but with a few differences, such as different status. For example:

Tables\Columns\TextColumn::make('parking_spots_count')
    ->label('Total Parking Spots')
    ->counts('parkingSpots'),
Tables\Columns\TextColumn::make('parking_spots_available_count')
    ->label('Available Parking Spots')
    ->counts([
        'parkingSpots' => fn (Builder $query) => $query->where('status', 'available'),
    ]),
Tables\Columns\TextColumn::make('parking_spots_count')
    ->label('Total Parking Spots')
    ->counts('parkingSpots'),
Tables\Columns\TextColumn::make('parking_spots_available_count')
    ->label('Available Parking Spots')
    ->counts([
        'parkingSpots' => fn (Builder $query) => $query->where('status', 'available'),
    ]),


both of these columns work when used alone, but they don't work together (there's no error, they just don't show data). I tried using one of them as "sum" or changing the "make" name, but I could not make it work, I'm reading the docs but I can't find a best practice solution for that
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

Multiple columns from the same relationship in an ExportAction
FilamentFFilament / ❓┊help
2y ago
Import CSV multiple columns in one relationship
FilamentFFilament / ❓┊help
17mo ago
Multiple columns of same attribute
FilamentFFilament / ❓┊help
3y ago
Multiple Layout Components with same Relationship
FilamentFFilament / ❓┊help
7mo ago