Skip to content

Commit

Permalink
Add methods to retrieve resource table data
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithDennis committed Mar 13, 2024
1 parent fcd2225 commit 39fd902
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/Commands/FilamentResourceTestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
namespace CodeWithDennis\FilamentResourceTests\Commands;

use Filament\Facades\Filament;
use Filament\Resources\Pages\ListRecords;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use Illuminate\Console\Command;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Collection;
Expand All @@ -16,7 +18,7 @@ class FilamentResourceTestsCommand extends Command

protected $description = 'Create a new test for a Filament resource.';

protected ?string $resourceName;
protected ?string $resourceName = '';

protected Filesystem $files;

Expand Down Expand Up @@ -109,19 +111,21 @@ protected function getResources(): Collection
return collect(Filament::getResources());
}

protected function getResourceTableColumns()
protected function getResourceTableColumns(): array
{
// TODO: Get the table columns of the given filament resource
$livewire = app('livewire')->new(ListRecords::class);

return $this->getResourceClass()::table(new Table($livewire))->getColumns();
}

protected function getResourceSortableTableColumns()
protected function getResourceSortableTableColumns(): Collection
{
// TODO: Get the table sortable columns of the given filament resource
return collect($this->getResourceTableColumns())->filter(fn ($column) => $column->isSortable());
}

protected function getResourceSearchableTableColumns()
protected function getResourceSearchableTableColumns(): Collection
{
// TODO: Get the table searchable columns of the given filament resource
return collect($this->getResourceTableColumns())->filter(fn ($column) => $column->isSearchable());
}

protected function getResourceTableFilters()
Expand Down

0 comments on commit 39fd902

Please sign in to comment.