F
Filament15mo ago
Wazza

Widget error $tableColumnSearches

Hi everyone, Im having a issue thats driving me nuts... Im trying to make a widget update depending on what I choose from the table filter but I keep getting this issue everytime I change the filter on the table On my AnalyticsResource I have ExposesTableToWidgets and also included the
public static function getWidgets(): array
{
return [
AnalyticStats::class,
];
}
public static function getWidgets(): array
{
return [
AnalyticStats::class,
];
}
on the AnalyticStats I have use InteractsWithPageTable; looks like this
class AnalyticStats extends BaseWidget
{
use InteractsWithPageTable;

public ?Model $record = null;

protected function getTablePage(): string
{
return ListAnalytics::class;
}

protected function getStats(): array
{
return [
Stat::make('Total Analytics', $this->getPageTableQuery()->count()),
];
}
}
class AnalyticStats extends BaseWidget
{
use InteractsWithPageTable;

public ?Model $record = null;

protected function getTablePage(): string
{
return ListAnalytics::class;
}

protected function getStats(): array
{
return [
Stat::make('Total Analytics', $this->getPageTableQuery()->count()),
];
}
}
All im trying to do is filter the count depending on the filter between dates, Ive pretty much duplicated whats on the demo project. Any help would be great.. Thanks in advance
No description
7 Replies
cheesegrits
cheesegrits15mo ago
Can you share the full Flare error. I assume it's coming from line 75 in InteractsWithPageTable, but would help to be sure.
ChesterS
ChesterS15mo ago
FWIW i'm getting the same issue. I tried going through it with the debugger and it never hits the InteractsWithPageTable::getTablePageInstance() method. I might be missing something though. here is a repo that has the minimum code to reproduce it : https://github.com/sprtk-ches/laravel-filament Once you migrate + seed + build and navigate to /users you can just type anything in search and it will trigger the error Might raise a ticket for this 🤔
Wazza
WazzaOP15mo ago
Sorry been away on a trip, ill see if I can grab the full flare error once I get the project up and running.. @ChesterS Thats the issue im having at the moment, I might update to the latest version of filament and see if its still an issue, atleast im not alone on this problem ahah
ChesterS
ChesterS15mo ago
@Wazza FWIW adding public array $tableColumnSearches = []; to the widget class (AnalyticStats) seems to solve the issue. However I've found another issue where getPageTableQuery() and getPageTableRecords() don't return the correct results based on the filters that are active
Wazza
WazzaOP15mo ago
Here is the flare @Hugh Messenger https://flareapp.io/share/x7Kbk8eP#context-request-browser @Hugh Messenger That fixes the error but you are right is causes the normal filter to break
Flare
Cannot assign null to property App\Filament\Resources\AnalyticResource\Widgets\AnalyticStats::$tableColumnSearches of type array - The error occurred at http://localhost/admin/analytics
ChesterS
ChesterS15mo ago
The normal filter is broken even without that. You can test it yourself 1. getPageTableRecords() returns more results than the actual total of the page 2. getPageTableQuery() ignores the filters. You can test that by adding some default filters - if you count() the query results, you'll see that your total is more than it should. In any case, there's something wrong there and it's easily reproducible
Wazza
WazzaOP15mo ago
Okay so I managed to fix it, I made a mistake on where I was adding the logic So use ExposesTableToWidgets; needs to be in the ListAnalytics I had mine on the AnalyticsResource
Want results from more Discord servers?
Add your server