Skip to content

Commit

Permalink
refactor: Remove unnecessary property and simplify code logic
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWithDennis committed Mar 16, 2024
1 parent 31e50ff commit 49acfbb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/Commands/FilamentResourceTestsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class FilamentResourceTestsCommand extends Command

protected Filesystem $files;

protected string $tests = '';

public function __construct(Filesystem $files)
{
parent::__construct();
Expand All @@ -42,17 +40,18 @@ protected function convertDoubleQuotedArrayString(string $string): array|string
protected function getStubVariables(Resource $resource): array
{
$model = $resource->getModel();
$columns = collect($this->getResourceTable($resource)->getColumns());

return [
'resource' => str($resource::class)->afterLast('\\'),
'model' => $model,
'modelSingularName' => str($model)->afterLast('\\'),
'modelPluralName' => str($model)->afterLast('\\')->plural(),
'resourceTableColumns' => $this->convertDoubleQuotedArrayString(collect($this->getResourceTable($resource)->getColumns())->keys()),
'resourceTableColumnsWithoutHidden' => $this->convertDoubleQuotedArrayString(collect($this->getResourceTable($resource)->getColumns())->filter(fn ($column) => ! $column->isToggledHiddenByDefault())->keys()),
'resourceTableToggleableColumns' => $this->convertDoubleQuotedArrayString(collect($this->getResourceTable($resource)->getColumns())->filter(fn ($column) => $column->isToggleable())->keys()),
'resourceTableSortableColumns' => $this->convertDoubleQuotedArrayString(collect($this->getResourceTable($resource)->getColumns())->filter(fn ($column) => $column->isSortable())->keys()),
'resourceTableSearchableColumns' => $this->convertDoubleQuotedArrayString(collect($this->getResourceTable($resource)->getColumns())->filter(fn ($column) => $column->isSearchable())->keys()),
'resourceTableColumns' => $this->convertDoubleQuotedArrayString($columns->keys()),
'resourceTableColumnsWithoutHidden' => $this->convertDoubleQuotedArrayString($columns->filter(fn ($column) => ! $column->isToggledHiddenByDefault())->keys()),
'resourceTableToggleableColumns' => $this->convertDoubleQuotedArrayString($columns->filter(fn ($column) => $column->isToggleable())->keys()),
'resourceTableSortableColumns' => $this->convertDoubleQuotedArrayString($columns->filter(fn ($column) => $column->isSortable())->keys()),
'resourceTableSearchableColumns' => $this->convertDoubleQuotedArrayString($columns->filter(fn ($column) => $column->isSearchable())->keys()),
];
}

Expand Down

0 comments on commit 49acfbb

Please sign in to comment.