F
Filamentβ€’10mo ago
Wannes

Get all sortable columns of table

Hi, I'm trying to create some automated tests. So basically I want to execute all these tests (https://filamentphp.com/docs/3.x/tables/testing), but I'm trying to automate them. Now I'm wondering how I could get all the columns of my table which I specified with ->sortable() in my resource. Than I can just create a loop and execute my tests based on the fields.
Solution:
return collect($this->getResourceTableColumns())
->filter(fn ($column) => $column->isSortable());
return collect($this->getResourceTableColumns())
->filter(fn ($column) => $column->isSortable());
...
Jump to solution
6 Replies
BlackShadow
BlackShadowβ€’9mo ago
Did you figure it out?
Wannes
WannesOPβ€’9mo ago
No, unfortunately not
BlackShadow
BlackShadowβ€’9mo ago
$livewire = app('livewire')->new(ListRecords::class);

return BlogResource::table(new Table($livewire))->getColumns();
$livewire = app('livewire')->new(ListRecords::class);

return BlogResource::table(new Table($livewire))->getColumns();
Mark Chaney
Mark Chaneyβ€’9mo ago
that will just get all columns though and not all sortable columns, right? Probably like us, wants to make sure sorting a column or searching on a table doesnt throw any errors.
Solution
BlackShadow
BlackShadowβ€’9mo ago
return collect($this->getResourceTableColumns())
->filter(fn ($column) => $column->isSortable());
return collect($this->getResourceTableColumns())
->filter(fn ($column) => $column->isSortable());
Wannes
WannesOPβ€’9mo ago
Awesome, thanks! πŸ™
Want results from more Discord servers?
Add your server