F
Filament7mo 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() 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(),
]);
}
0 Replies
No replies yetBe the first to reply to this messageJoin