Athror
Athror
FFilament
Created by Athror on 6/16/2024 in #❓┊help
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?
3 replies