From 069ab4552f855b78a5cedba2d5565bf578632844 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Tue, 5 Mar 2024 13:57:34 +0000 Subject: [PATCH] Revert "Merge pull request #11664 from SanderMuller/3.x" This reverts commit 0322adc3bd8951a59a34e69511a9f0355b115ecf, reversing changes made to 0f350f69a2dc4476394f3e4df5d4ed3e6188b901. --- packages/tables/src/Columns/Column.php | 17 ++--------------- tests/src/Tables/ColumnTest.php | 7 ------- tests/src/Tables/Fixtures/PostsTable.php | 10 ---------- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/packages/tables/src/Columns/Column.php b/packages/tables/src/Columns/Column.php index 7651d514ce..51148e78e1 100644 --- a/packages/tables/src/Columns/Column.php +++ b/packages/tables/src/Columns/Column.php @@ -58,27 +58,14 @@ class Column extends ViewComponent $this->name($name); } - public static function make(?string $name = null): static + public static function make(string $name): static { - $columnClass = static::class; - - $name ??= static::getDefaultName(); - - if (blank($name)) { - throw new Exception("Column of class [$columnClass] must have a unique name, passed to the [make()] method."); - } - - $static = app($columnClass, ['name' => $name]); + $static = app(static::class, ['name' => $name]); $static->configure(); return $static; } - public static function getDefaultName(): ?string - { - return null; - } - public function getTable(): Table { return $this->table ?? $this->getGroup()?->getTable() ?? $this->getLayout()?->getTable() ?? throw new Exception("The column [{$this->getName()}] is not mounted to a table."); diff --git a/tests/src/Tables/ColumnTest.php b/tests/src/Tables/ColumnTest.php index 1d7acbb7db..f286ccd9e0 100644 --- a/tests/src/Tables/ColumnTest.php +++ b/tests/src/Tables/ColumnTest.php @@ -23,13 +23,6 @@ it('can render text column with relationship', function () { ->assertCanRenderTableColumn('author.name'); }); -it('can render column with default name', function () { - Post::factory()->count(10)->create(); - - livewire(PostsTable::class) - ->assertCanRenderTableColumn('created_at'); -}); - it('can sort records', function () { $posts = Post::factory()->count(10)->create(); diff --git a/tests/src/Tables/Fixtures/PostsTable.php b/tests/src/Tables/Fixtures/PostsTable.php index 3adb94554a..8ae687d533 100644 --- a/tests/src/Tables/Fixtures/PostsTable.php +++ b/tests/src/Tables/Fixtures/PostsTable.php @@ -7,7 +7,6 @@ use Filament\Forms\Components\TextInput; use Filament\Forms\Concerns\InteractsWithForms; use Filament\Forms\Contracts\HasForms; use Filament\Tables; -use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; use Filament\Tests\Models\Post; use Illuminate\Contracts\View\View; @@ -88,7 +87,6 @@ class PostsTable extends Component implements HasForms, Tables\Contracts\HasTabl ->sortable() ->searchable() ->prefix(fn (Post $record): string => $record->is_published ? 'published' : 'unpublished'), - CreatedAtColumn::make(), ]) ->filters([ Tables\Filters\Filter::make('is_published') @@ -200,11 +198,3 @@ class PostsTable extends Component implements HasForms, Tables\Contracts\HasTabl return view('tables.fixtures.table'); } } - -class CreatedAtColumn extends TextColumn -{ - public static function getDefaultName(): ?string - { - return 'created_at'; - } -}