Update table actions when change filter

I need to change the visibility of the actions when I change the filter. I have the following code so that it is not calculating the state in each record, but it does not update the visibility of the button until I refresh with F5 or click any action. If I do the find on each record it generates a large number of unnecessary queries.
protected function getTableActions(): array
{
$this->initializePermissions();

// Retrieve the auth_status value
$legAuthStatus = $this->record->legs->find($this->getTableFilterState('leg')['value'])->auth_status ?? null;
$isNotOfficial = $legAuthStatus != EntryListEnum::Official;

return [
Tables\Actions\ViewAction::make()
->iconButton()
->modalWidth(MaxWidth::Medium),
Tables\Actions\EditAction::make()
->iconButton()
->modalWidth(MaxWidth::Medium)
->visible(fn($record, $livewire) => $this->canEditAuthorization && $isNotOfficial),
Tables\Actions\DeleteAction::make()
->iconButton()
->visible(fn($record, $livewire) => $this->canDeleteAuthorization && $isNotOfficial),
];
}
protected function getTableActions(): array
{
$this->initializePermissions();

// Retrieve the auth_status value
$legAuthStatus = $this->record->legs->find($this->getTableFilterState('leg')['value'])->auth_status ?? null;
$isNotOfficial = $legAuthStatus != EntryListEnum::Official;

return [
Tables\Actions\ViewAction::make()
->iconButton()
->modalWidth(MaxWidth::Medium),
Tables\Actions\EditAction::make()
->iconButton()
->modalWidth(MaxWidth::Medium)
->visible(fn($record, $livewire) => $this->canEditAuthorization && $isNotOfficial),
Tables\Actions\DeleteAction::make()
->iconButton()
->visible(fn($record, $livewire) => $this->canDeleteAuthorization && $isNotOfficial),
];
}
Thanks
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?