mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 01:58:00 +08:00
Revert "Merge pull request #11664 from SanderMuller/3.x"
This reverts commit0322adc3bd, reversing changes made to0f350f69a2.
This commit is contained in:
@@ -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.");
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user