© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago
Veur

TextColumn with subquery value

I have a Filament Table (outside a panel) listing records from a relationship.
In the select statement of the query I added a subquery, which counts a certain number of records.
But the value from the subquery isn't displayed in the table. While I see the attribute has a value when I
dd()
dd()
the query.
Any ideas? Below is the $table code:
public function table(Table $table): Table
{
    return $table
        ->relationship(fn (): HasMany => $this->user->clients()
            ->addSelect([
                'vacancies_count' => Vacancy::query()
                    ->selectRaw('COUNT(*)')
                    ->whereColumn('client_id', 'teams.id')
                    ->active()
            ])
        )
        ->inverseRelationship('user')
        ->columns([
            TextColumn::make('vacancies_count')
                ->sortable(),
        ]);
}
public function table(Table $table): Table
{
    return $table
        ->relationship(fn (): HasMany => $this->user->clients()
            ->addSelect([
                'vacancies_count' => Vacancy::query()
                    ->selectRaw('COUNT(*)')
                    ->whereColumn('client_id', 'teams.id')
                    ->active()
            ])
        )
        ->inverseRelationship('user')
        ->columns([
            TextColumn::make('vacancies_count')
                ->sortable(),
        ]);
}
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

sort TextColumn with multiple value
FilamentFFilament / ❓┊help
2y ago
TextColumn depending on database value....
FilamentFFilament / ❓┊help
4mo ago
Custom value of textcolumn description
FilamentFFilament / ❓┊help
3y ago
TextColumn relationship unique values
FilamentFFilament / ❓┊help
3y ago