From d2ebe8d66676bfeec2a8b4232f520e905f9ce33e Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Wed, 10 Mar 2021 23:13:06 +0000 Subject: [PATCH 01/11] Update FilamentServiceProvider.php --- src/FilamentServiceProvider.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/FilamentServiceProvider.php b/src/FilamentServiceProvider.php index 394e9fe1dfe..22e1b16fb7a 100644 --- a/src/FilamentServiceProvider.php +++ b/src/FilamentServiceProvider.php @@ -34,6 +34,7 @@ public function boot() $this->bootLoaders(); $this->bootLivewireComponents(); $this->bootPublishing(); + $this->configure(); } @@ -195,9 +196,7 @@ protected function registerIcons() protected function registerProviders() { - $this->app->booted(function () { - $this->app->register(RouteServiceProvider::class); - }); + $this->app->register(RouteServiceProvider::class); } protected function mergeConfigFrom($path, $key) From 5073d82b8499527312c8300e07efeabe2aaa3aaf Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Wed, 10 Mar 2021 23:33:32 +0000 Subject: [PATCH 02/11] Delete Sushi.php --- src/Sushi.php | 174 -------------------------------------------------- 1 file changed, 174 deletions(-) delete mode 100644 src/Sushi.php diff --git a/src/Sushi.php b/src/Sushi.php deleted file mode 100644 index 62b035bf668..00000000000 --- a/src/Sushi.php +++ /dev/null @@ -1,174 +0,0 @@ -getFileName(); - - $states = [ - 'cache-file-found-and-up-to-date' => function () use ($cachePath) { - static::setSqliteConnection($cachePath); - }, - 'cache-file-not-found-or-stale' => function () use ($cachePath, $modelPath, $instance) { - file_put_contents($cachePath, ''); - - static::setSqliteConnection($cachePath); - - $instance->migrate(); - - touch($cachePath, filemtime($modelPath)); - }, - 'no-caching-capabilities' => function () use ($instance) { - static::setSqliteConnection(':memory:'); - - $instance->migrate(); - }, - ]; - - switch (true) { - case ! property_exists($instance, 'rows'): - $states['no-caching-capabilities'](); - break; - - case file_exists($cachePath) && filemtime($modelPath) <= filemtime($cachePath): - $states['cache-file-found-and-up-to-date'](); - break; - - case file_exists($cacheDirectory) && is_writable($cacheDirectory): - $states['cache-file-not-found-or-stale'](); - break; - - default: - $states['no-caching-capabilities'](); - break; - } - } - - public static function resolveConnection($connection = null) - { - return static::$sushiConnection; - } - - protected static function setSqliteConnection($database) - { - static::$sushiConnection = app(ConnectionFactory::class)->make([ - 'driver' => 'sqlite', - 'database' => $database, - ]); - } - - public function migrate() - { - $rows = $this->getRows(); - $tableName = $this->getTable(); - - if (count($rows)) { - $this->createTable($tableName, $rows[0]); - } else { - $this->createTableWithNoData($tableName); - } - - static::insert($rows); - } - - public function getRows() - { - return $this->rows; - } - - public function createTable(string $tableName, $firstRow) - { - static::resolveConnection()->getSchemaBuilder()->create($tableName, function ($table) use ($firstRow) { - // Add the "id" column if it doesn't already exist in the rows. - if ($this->incrementing && ! in_array($this->primaryKey, array_keys($firstRow))) { - $table->increments($this->primaryKey); - } - - foreach ($firstRow as $column => $value) { - switch (true) { - case is_int($value): - $type = 'integer'; - break; - case is_numeric($value): - $type = 'float'; - break; - case is_string($value): - $type = 'string'; - break; - case is_object($value) && $value instanceof DateTime: - $type = 'dateTime'; - break; - default: - $type = 'string'; - } - - if ($column === $this->primaryKey && $type == 'integer') { - $table->increments($this->primaryKey); - continue; - } - - $schema = $this->getSchema(); - - $type = $schema[$column] ?? $type; - - $table->{$type}($column)->nullable(); - } - - if ($this->usesTimestamps() && (! in_array('updated_at', array_keys($firstRow)) || ! in_array('created_at', array_keys($firstRow)))) { - $table->timestamps(); - } - }); - } - - public function getSchema() - { - return $this->schema ?? []; - } - - public function usesTimestamps() - { - // Override the Laravel default value of $timestamps = true; Unless otherwise set. - return (new ReflectionClass($this))->getProperty('timestamps')->class === static::class - ? parent::usesTimestamps() - : false; - } - - public function createTableWithNoData(string $tableName) - { - static::resolveConnection()->getSchemaBuilder()->create($tableName, function ($table) { - $schema = $this->schema; - - if ($this->incrementing && ! in_array($this->primaryKey, array_keys($schema))) { - $table->increments($this->primaryKey); - } - - foreach ($schema as $name => $type) { - if ($name === $this->primaryKey && $type == 'integer') { - $table->increments($this->primaryKey); - continue; - } - - $table->{$type}($name)->nullable(); - } - - if ($this->usesTimestamps() && (! in_array('updated_at', array_keys($schema)) || ! in_array('created_at', array_keys($schema)))) { - $table->timestamps(); - } - }); - } -} From 52d449b7bebe28115f2fc23626858c891d29d217 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Wed, 10 Mar 2021 12:31:57 +0000 Subject: [PATCH 03/11] feature: add support for class based filters --- packages/tables/src/Filter.php | 7 +++++++ packages/tables/src/HasTable.php | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/tables/src/Filter.php b/packages/tables/src/Filter.php index fae81db153a..1c77c68776a 100644 --- a/packages/tables/src/Filter.php +++ b/packages/tables/src/Filter.php @@ -41,6 +41,13 @@ public function callback($callback) return $this; } + public function apply($query) + { + $callback = $this->callback; + + return $callback($query); + } + public function context($context) { $this->context = $context; diff --git a/packages/tables/src/HasTable.php b/packages/tables/src/HasTable.php index 6bc9604eec7..43e040ded94 100644 --- a/packages/tables/src/HasTable.php +++ b/packages/tables/src/HasTable.php @@ -118,9 +118,7 @@ public function getRecords() collect($this->getTable()->filters) ->filter(fn ($filter) => $filter->name === $this->filter) ->each(function ($filter) use (&$query) { - $callback = $filter->callback; - - $query = $callback($query); + $query = $filter->apply($query); }); } From 20b7a05312de366ec76c8db4ac2d28a2fb01f544 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Wed, 10 Mar 2021 12:33:35 +0000 Subject: [PATCH 04/11] feature: add setUp method and make name nullable --- packages/tables/src/Filter.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/tables/src/Filter.php b/packages/tables/src/Filter.php index 1c77c68776a..c121d0b1bfd 100644 --- a/packages/tables/src/Filter.php +++ b/packages/tables/src/Filter.php @@ -23,10 +23,20 @@ class Filter protected $pendingIncludedContextModifications = []; - public function __construct($name, $callback = null) + public function __construct($name = null, $callback = null) { - $this->name($name); + if ($name) { + $this->name($name); + } + $this->callback($callback); + + $this->setUp(); + } + + protected function setUp() + { + // } public static function make($name, $callback = null) From 9eef64485e8926d6abfd899272413b6c16e3d884 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Wed, 10 Mar 2021 12:33:53 +0000 Subject: [PATCH 05/11] fix: make $name nullable --- packages/tables/src/Filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tables/src/Filter.php b/packages/tables/src/Filter.php index c121d0b1bfd..b4b9e119307 100644 --- a/packages/tables/src/Filter.php +++ b/packages/tables/src/Filter.php @@ -39,7 +39,7 @@ protected function setUp() // } - public static function make($name, $callback = null) + public static function make($name = null, $callback = null) { return new static($name, $callback); } From 28e3d0ddc9c3ed6704e365b10f7b5b0b33d01ad9 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Wed, 10 Mar 2021 12:43:29 +0000 Subject: [PATCH 06/11] feature: filament-filter command --- src/Commands/Aliases/MakeFilterCommand.php | 8 ++++ src/Commands/MakeFilterCommand.php | 48 ++++++++++++++++++++++ src/FilamentServiceProvider.php | 1 + stubs/Filter.stub | 18 ++++++++ 4 files changed, 75 insertions(+) create mode 100644 src/Commands/Aliases/MakeFilterCommand.php create mode 100644 src/Commands/MakeFilterCommand.php create mode 100644 stubs/Filter.stub diff --git a/src/Commands/Aliases/MakeFilterCommand.php b/src/Commands/Aliases/MakeFilterCommand.php new file mode 100644 index 00000000000..bbe00740aca --- /dev/null +++ b/src/Commands/Aliases/MakeFilterCommand.php @@ -0,0 +1,8 @@ +argument('name')) + ->trim('/') + ->trim('\\') + ->trim(' ') + ->replace('/', '\\'); + + $filterClass = (string) Str::of($filter)->afterLast('\\'); + $filterNamespace = Str::of($filter)->contains('\\') ? + (string) Str::of($filter)->beforeLast('\\') : + ''; + + $path = app_path( + (string) Str::of($filter) + ->prepend('Filament\\Filters\\') + ->replace('\\', '/') + ->append('.php'), + ); + + if ($this->checkForCollision([ + $path, + ])) return; + + $this->copyStubToApp('Filter', $path, [ + 'class' => $filterClass, + 'name' => $filter, + 'namespace' => 'App\\Filament\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), + ]); + + $this->info("Successfully created {$filter}!"); + } +} diff --git a/src/FilamentServiceProvider.php b/src/FilamentServiceProvider.php index 22e1b16fb7a..97a680152ba 100644 --- a/src/FilamentServiceProvider.php +++ b/src/FilamentServiceProvider.php @@ -66,6 +66,7 @@ protected function bootCommands() Commands\MakeWidgetCommand::class, Commands\MakeFieldCommand::class, Commands\MakeThemeCommand::class, + Commands\MakeFilterCommand::class, ]); $aliases = []; diff --git a/stubs/Filter.stub b/stubs/Filter.stub new file mode 100644 index 00000000000..c16ebf87731 --- /dev/null +++ b/stubs/Filter.stub @@ -0,0 +1,18 @@ +name('{{ name }}'); + } + + public function apply($query) + { + return $query; + } +} From eb2a9e56cf5b4b13b829cf317fd17471be76e9d3 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Wed, 10 Mar 2021 23:49:58 +0000 Subject: [PATCH 07/11] Primary column actions and urls --- .../views/components/file-upload.blade.php | 2 +- .../resources/views/cells/icon.blade.php | 10 +++---- .../resources/views/cells/image.blade.php | 6 ++--- .../resources/views/cells/text.blade.php | 6 ++--- .../src/Columns/Concerns/CanCallAction.php | 13 ++++++++++ .../src/Columns/Concerns/CanOpenUrl.php | 2 ++ packages/tables/src/Table.php | 26 +++++++++++++++++++ src/Resources/Pages/ListRecords.php | 8 ++++++ src/Resources/RelationManager.php | 5 ++++ 9 files changed, 66 insertions(+), 12 deletions(-) diff --git a/packages/forms/resources/views/components/file-upload.blade.php b/packages/forms/resources/views/components/file-upload.blade.php index 5b33aeedbdb..6f90ac07f0d 100644 --- a/packages/forms/resources/views/components/file-upload.blade.php +++ b/packages/forms/resources/views/components/file-upload.blade.php @@ -61,7 +61,7 @@ FilePond.registerPlugin(FilePondPluginImageTransform) let config = { - acceptedFileTypes: @json($formComponent->acceptedFileTypes), + acceptedFileTypes: {{ json_encode($formComponent->acceptedFileTypes) }}, files: [], {{ $formComponent->imageCropAspectRatio !== null ? "imageCropAspectRatio: '{$formComponent->imageCropAspectRatio}'," : null }} {{ $formComponent->imagePreviewHeight !== null ? "imagePreviewHeight: {$formComponent->imagePreviewHeight}," : null }} diff --git a/packages/tables/resources/views/cells/icon.blade.php b/packages/tables/resources/views/cells/icon.blade.php index 6cb9876001b..74a63a89dd3 100644 --- a/packages/tables/resources/views/cells/icon.blade.php +++ b/packages/tables/resources/views/cells/icon.blade.php @@ -13,19 +13,19 @@ @endphp @if ($iconToShow) - @if ($column->action) + @if ($column->getAction($record) !== null) - @elseif ($column->url) + @elseif ($column->getUrl($record) !== null) shouldOpenUrlInNewTab) - target="_blank" - rel="noopener noreferrer" + target="_blank" + rel="noopener noreferrer" @endif > diff --git a/packages/tables/resources/views/cells/image.blade.php b/packages/tables/resources/views/cells/image.blade.php index 4476baf1412..2ba57a93939 100644 --- a/packages/tables/resources/views/cells/image.blade.php +++ b/packages/tables/resources/views/cells/image.blade.php @@ -1,6 +1,6 @@ -@if ($column->action) +@if ($column->getAction($record) !== null) -@elseif ($column->url) +@elseif ($column->getUrl($record) !== null) shouldOpenUrlInNewTab) diff --git a/packages/tables/resources/views/cells/text.blade.php b/packages/tables/resources/views/cells/text.blade.php index f2df7aa8aea..6cd01455299 100644 --- a/packages/tables/resources/views/cells/text.blade.php +++ b/packages/tables/resources/views/cells/text.blade.php @@ -3,15 +3,15 @@ @endphp
- @if ($column->action) + @if ($column->getAction($record) !== null) - @elseif ($column->url) + @elseif ($column->getUrl($record) !== null) action === null) return null; + + if (is_callable($this->action)) { + $callback = $this->action; + + return $callback($record); + } + + return $this->action; + } } diff --git a/packages/tables/src/Columns/Concerns/CanOpenUrl.php b/packages/tables/src/Columns/Concerns/CanOpenUrl.php index f9d85834b09..101fea1287d 100644 --- a/packages/tables/src/Columns/Concerns/CanOpenUrl.php +++ b/packages/tables/src/Columns/Concerns/CanOpenUrl.php @@ -10,6 +10,8 @@ trait CanOpenUrl public function getUrl($record) { + if ($this->url === null) return null; + if (is_callable($this->url)) { $callback = $this->url; diff --git a/packages/tables/src/Table.php b/packages/tables/src/Table.php index c9a489d6449..5fff1618756 100644 --- a/packages/tables/src/Table.php +++ b/packages/tables/src/Table.php @@ -12,6 +12,10 @@ class Table public $pagination = true; + public $primaryColumnAction; + + public $primaryColumnUrl; + public $recordActions = []; public $searchable = true; @@ -138,6 +142,28 @@ public function pagination($enabled) return $this; } + public function primaryRecordAction($action) + { + $this->columns = collect($this->columns) + ->map(function ($column) use ($action) { + return $column->action($action); + }) + ->toArray(); + + return $this; + } + + public function primaryRecordUrl($url) + { + $this->columns = collect($this->columns) + ->map(function ($column) use ($url) { + return $column->url($url); + }) + ->toArray(); + + return $this; + } + public function recordActions($actions) { $this->recordActions = $actions; diff --git a/src/Resources/Pages/ListRecords.php b/src/Resources/Pages/ListRecords.php index d0b5e97ca61..7d477d925fa 100644 --- a/src/Resources/Pages/ListRecords.php +++ b/src/Resources/Pages/ListRecords.php @@ -80,6 +80,14 @@ public function getTable() ->context(static::class) ->filterable($this->filterable) ->pagination($this->pagination) + ->primaryRecordUrl(function ($record) { + if (! Filament::can('update', $record)) return; + + return $this->getResource()::generateUrl( + $this->recordRoute, + ['record' => $record], + ); + }) ->recordActions([ RecordActions\Link::make('edit') ->label(static::$editRecordActionLabel) diff --git a/src/Resources/RelationManager.php b/src/Resources/RelationManager.php index 19f858da598..8282ff5948c 100644 --- a/src/Resources/RelationManager.php +++ b/src/Resources/RelationManager.php @@ -166,6 +166,11 @@ public function getTable() return static::table(Table::make()) ->filterable($this->filterable) ->pagination(false) + ->primaryRecordAction(function ($record) { + if (! Filament::can('update', $record)) return; + + return 'openEdit'; + }) ->recordActions([ RecordActions\Link::make('edit') ->label(static::$editRecordActionLabel) From e18005b28b67df462ced66c93c27baa5859f67ea Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Wed, 10 Mar 2021 23:52:20 +0000 Subject: [PATCH 08/11] feature: resource based filters --- src/Commands/Aliases/MakeFilterCommand.php | 2 +- src/Commands/MakeFilterCommand.php | 21 ++++++++++++++------- stubs/Filter.stub | 2 +- stubs/ResourceFilter.stub | 18 ++++++++++++++++++ 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 stubs/ResourceFilter.stub diff --git a/src/Commands/Aliases/MakeFilterCommand.php b/src/Commands/Aliases/MakeFilterCommand.php index bbe00740aca..e439f5cceb9 100644 --- a/src/Commands/Aliases/MakeFilterCommand.php +++ b/src/Commands/Aliases/MakeFilterCommand.php @@ -4,5 +4,5 @@ class MakeFilterCommand extends \Filament\Commands\MakeFilterCommand { - protected $signature = 'filament:filter {name}'; + protected $signature = 'filament:filter {name} {--R|resource=}'; } diff --git a/src/Commands/MakeFilterCommand.php b/src/Commands/MakeFilterCommand.php index edcaa6eec12..fb646907568 100644 --- a/src/Commands/MakeFilterCommand.php +++ b/src/Commands/MakeFilterCommand.php @@ -11,7 +11,7 @@ class MakeFilterCommand extends Command protected $description = 'Make a Filament filter class.'; - protected $signature = 'make:filament-filter {name}'; + protected $signature = 'make:filament-filter {name} {--R|resource=}'; public function handle() { @@ -20,12 +20,13 @@ public function handle() ->trim('\\') ->trim(' ') ->replace('/', '\\'); - $filterClass = (string) Str::of($filter)->afterLast('\\'); $filterNamespace = Str::of($filter)->contains('\\') ? (string) Str::of($filter)->beforeLast('\\') : ''; + $resource = $this->option('resource'); + $path = app_path( (string) Str::of($filter) ->prepend('Filament\\Filters\\') @@ -37,11 +38,17 @@ public function handle() $path, ])) return; - $this->copyStubToApp('Filter', $path, [ - 'class' => $filterClass, - 'name' => $filter, - 'namespace' => 'App\\Filament\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), - ]); + if ($resource === null) { + $this->copyStubToApp('Filter', $path, [ + 'class' => $filterClass, + 'namespace' => 'App\\Filament\\Filters', + ]); + } else { + $this->copyStubToApp('ResourceFilter', $path, [ + 'class' => $filterClass, + 'namespace' => 'App\\Filament\\Filters', + ]); + } $this->info("Successfully created {$filter}!"); } diff --git a/stubs/Filter.stub b/stubs/Filter.stub index c16ebf87731..ca26dd7d0aa 100644 --- a/stubs/Filter.stub +++ b/stubs/Filter.stub @@ -2,7 +2,7 @@ namespace {{ namespace }}; -use Filament\Resources\Tables\Filter; +use Filament\Tables\Filter; class {{ class }} extends Filter { diff --git a/stubs/ResourceFilter.stub b/stubs/ResourceFilter.stub new file mode 100644 index 00000000000..c16ebf87731 --- /dev/null +++ b/stubs/ResourceFilter.stub @@ -0,0 +1,18 @@ +name('{{ name }}'); + } + + public function apply($query) + { + return $query; + } +} From 05bc6bcfef10ccd88074530594f53440600abe6e Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Wed, 10 Mar 2021 23:56:45 +0000 Subject: [PATCH 09/11] fix: publish to correct paths --- src/Commands/Aliases/MakeFilterCommand.php | 2 +- src/Commands/MakeFilterCommand.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Commands/Aliases/MakeFilterCommand.php b/src/Commands/Aliases/MakeFilterCommand.php index e439f5cceb9..570482bc13d 100644 --- a/src/Commands/Aliases/MakeFilterCommand.php +++ b/src/Commands/Aliases/MakeFilterCommand.php @@ -4,5 +4,5 @@ class MakeFilterCommand extends \Filament\Commands\MakeFilterCommand { - protected $signature = 'filament:filter {name} {--R|resource=}'; + protected $signature = 'filament:filter {name} {--R|resource}'; } diff --git a/src/Commands/MakeFilterCommand.php b/src/Commands/MakeFilterCommand.php index fb646907568..26e6e0e47bf 100644 --- a/src/Commands/MakeFilterCommand.php +++ b/src/Commands/MakeFilterCommand.php @@ -11,7 +11,7 @@ class MakeFilterCommand extends Command protected $description = 'Make a Filament filter class.'; - protected $signature = 'make:filament-filter {name} {--R|resource=}'; + protected $signature = 'make:filament-filter {name} {--R|resource}'; public function handle() { @@ -29,7 +29,7 @@ public function handle() $path = app_path( (string) Str::of($filter) - ->prepend('Filament\\Filters\\') + ->prepend($resource === null ? 'Filament\\Filters\\' : "Filament\\Resources\\Filters\\") ->replace('\\', '/') ->append('.php'), ); @@ -38,15 +38,15 @@ public function handle() $path, ])) return; - if ($resource === null) { + if ($resource === false) { $this->copyStubToApp('Filter', $path, [ 'class' => $filterClass, - 'namespace' => 'App\\Filament\\Filters', + 'namespace' => 'App\\Filament\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), ]); } else { $this->copyStubToApp('ResourceFilter', $path, [ 'class' => $filterClass, - 'namespace' => 'App\\Filament\\Filters', + 'namespace' => 'App\\Filament\\Resources\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), ]); } From 4da8f89d42ea172de39a2f487d1c94ada428e121 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Thu, 11 Mar 2021 00:05:19 +0000 Subject: [PATCH 10/11] chore: update namespaces --- src/Commands/MakeFilterCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/MakeFilterCommand.php b/src/Commands/MakeFilterCommand.php index 26e6e0e47bf..b9cbcc10da5 100644 --- a/src/Commands/MakeFilterCommand.php +++ b/src/Commands/MakeFilterCommand.php @@ -29,7 +29,7 @@ public function handle() $path = app_path( (string) Str::of($filter) - ->prepend($resource === null ? 'Filament\\Filters\\' : "Filament\\Resources\\Filters\\") + ->prepend($resource === null ? 'Filament\\Tables\\Filters\\' : "Filament\\Resources\\Tables\\Filters\\") ->replace('\\', '/') ->append('.php'), ); @@ -41,12 +41,12 @@ public function handle() if ($resource === false) { $this->copyStubToApp('Filter', $path, [ 'class' => $filterClass, - 'namespace' => 'App\\Filament\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), + 'namespace' => 'App\\Filament\\Tables\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), ]); } else { $this->copyStubToApp('ResourceFilter', $path, [ 'class' => $filterClass, - 'namespace' => 'App\\Filament\\Resources\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), + 'namespace' => 'App\\Filament\\Resources\\Tables\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''), ]); } From 60ff3c2a65147f30c5204bce934e673e3fd3ed8c Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Thu, 11 Mar 2021 00:10:32 +0000 Subject: [PATCH 11/11] formatting --- src/Commands/MakeFieldCommand.php | 2 +- src/Commands/MakeFilterCommand.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Commands/MakeFieldCommand.php b/src/Commands/MakeFieldCommand.php index 0c27bfc4c54..5403c7edd05 100644 --- a/src/Commands/MakeFieldCommand.php +++ b/src/Commands/MakeFieldCommand.php @@ -33,7 +33,7 @@ public function handle() $path = app_path( (string) Str::of($field) - ->prepend($this->option('resource') ? 'Filament\\Resources\\Forms\\Components\\' : "Filament\\Forms\\Components\\") + ->prepend($this->option('resource') ? 'Filament\\Resources\\Forms\\Components\\' : 'Filament\\Forms\\Components\\') ->replace('\\', '/') ->append('.php'), ); diff --git a/src/Commands/MakeFilterCommand.php b/src/Commands/MakeFilterCommand.php index b9cbcc10da5..6b3119cbd92 100644 --- a/src/Commands/MakeFilterCommand.php +++ b/src/Commands/MakeFilterCommand.php @@ -25,11 +25,9 @@ public function handle() (string) Str::of($filter)->beforeLast('\\') : ''; - $resource = $this->option('resource'); - $path = app_path( (string) Str::of($filter) - ->prepend($resource === null ? 'Filament\\Tables\\Filters\\' : "Filament\\Resources\\Tables\\Filters\\") + ->prepend($this->option('resource') ? 'Filament\\Resources\\Tables\\Filters\\' : 'Filament\\Tables\\Filters\\') ->replace('\\', '/') ->append('.php'), ); @@ -38,7 +36,7 @@ public function handle() $path, ])) return; - if ($resource === false) { + if (! $this->option('resource')) { $this->copyStubToApp('Filter', $path, [ 'class' => $filterClass, 'namespace' => 'App\\Filament\\Tables\\Filters' . ($filterNamespace !== '' ? "\\{$filterNamespace}" : ''),