Cannot delete record when having widget on Livewire component
When having a widget on a livewire component (front-end) and I try do delete a record, I got an error:
Cannot assign null to property App\Filament\Resources\ClientResource\Widgets\ClientsStats::$tableColumnSearches of type array I have use InteractsWithPageTable; in the widget class and use ExposesTableToWidgets;
If I remove the widgets, I can execute delete without a problem.
Here is the widget code:
class ClientsStats extends BaseWidget
{
use InteractsWithPageTable;
protected static ?string $pollingInterval = null;
protected static bool $isLazy = false;
protected function getTablePage(): string
{
if (request()->routeIs('clients.list')) {
return ClientList::class;
} else {
return ListClients::class;
}
}
protected function getStats(): array
{
return [
Stat::make(
'total_clients',
$this->getPageTableQuery()->count(),
)->label(__('Total Clients')),
Stat::make(
'draft',
$this->getPageTableQuery()
->where('statut', ClientStatut::DRAFT->value)
->count(),
)->label(__('Draft clients')),
Stat::make(
'approved_clients',
$this->getPageTableQuery()
->where('statut', ClientStatut::APPROVED->value)
->count(),
)->label(__('Approved clients')),
Stat::make(
'closed_clients',
$this->getPageTableQuery()
->where('statut', ClientStatut::CLOSED->value)
->count(),
)->label(__('Closed clients')),
];
}
}
In the error window inside the snaphost I get
"snapshot": "{"data":{"paginators":[[],{"s":"arr"}],"tableColumnSearches":[[],{"s":"arr"}],"tableGrouping":null,"tableGroupingDirection":null,"tableFilters":null,"tableRecordsPerPage":null,"tableSearch":"","tableSortColumn":null,"tableSortDirection":null,"activeTab":null},"memo":{"id":"wTgTFfasI30Q14iQ4yo1","name":"app.filament.resources.client-resource.widgets.clients-type-stats","path":"clients","method":"GET","children":[],"scripts":[],"assets":[],"props":["paginators","tableColumnSearches","tableGrouping","tableGroupingDirection","tableFilters","tableRecordsPerPage","tableSearch","tableSortColumn","tableSortDirection","activeTab"],"errors":[],"locale":"en"},}",
In the admin panel I have no issues.
Any help appreciated.
P.S: Forgot to mention, that this happens BEFORE the confirmation modal appears i.e. when I click delete from the table actions, instead of confirmation modal I got the above error.
Please or to participate in this conversation.