Revert "Merge pull request #11664 from SanderMuller/3.x"

This reverts commit 0322adc3bd, reversing
changes made to 0f350f69a2.
This commit is contained in:
Dan Harrin
2024-03-05 13:57:34 +00:00
parent 17b9554237
commit 069ab4552f
3 changed files with 2 additions and 32 deletions
+2 -15
View File
@@ -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.");
-7
View File
@@ -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();
-10
View File
@@ -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';
}
}