Refreshing Table after Attach Action

Hi everyone, I have two models Tag and Contact. In the View Tag page i want to see the list of tagged contacts. I have an attach button where I can tag other contacts. I have in the heading the counter of how many contacts that tag record has. However, when I attach a new contact to the tag the counter is not updated. Do you have any idea how to update the counter or move it where it can be updated? This is the table:
public function table(Table $table): Table
{

return $table
->heading('Contacts: ' . $this->ownerRecord->contacts->count())
->recordTitleAttribute('full_name')
->columns([
Tables\Columns\TextColumn::make('full_name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')
->label('Tagged At')->dateTime('j F Y, H:i'),
])
->headerActions([
Tables\Actions\AttachAction::make()
->color('info')
->preloadRecordSelect()
->after(function () {
// What can i add here?
}),
])
public function table(Table $table): Table
{

return $table
->heading('Contacts: ' . $this->ownerRecord->contacts->count())
->recordTitleAttribute('full_name')
->columns([
Tables\Columns\TextColumn::make('full_name'),
Tables\Columns\TextColumn::make('email'),
Tables\Columns\TextColumn::make('created_at')
->label('Tagged At')->dateTime('j F Y, H:i'),
])
->headerActions([
Tables\Actions\AttachAction::make()
->color('info')
->preloadRecordSelect()
->after(function () {
// What can i add here?
}),
])
I tried using the after action, however: - $this->resetTable(); does not work - $this->dispatch('$refresh) gives error Any help?
1 Reply
LeandroFerreira
GitHub
How to refresh table heading? · filamentphp filament · Discussion #...
Package Panel builder Package Version v3.2.40 How can we help you? Hi everyone, I have a Relationship Manager of belongs to many relationship. I have an attach action that works perfectly, but I wo...