refactor: Relocate news link display from its own table column to the title's description, remove the getRelations method, and enhance tags input with helper text.

This commit is contained in:
Yoga Pangestu 2026-03-13 09:39:39 +07:00
parent 6ced1ef7b4
commit 88c450af7f
3 changed files with 9 additions and 22 deletions

View File

@ -43,13 +43,6 @@ public static function table(Table $table): Table
return NewsTable::configure($table); return NewsTable::configure($table);
} }
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array public static function getPages(): array
{ {
return [ return [

View File

@ -45,7 +45,9 @@ public static function configure(Schema $schema): Schema
->placeholder('...') ->placeholder('...')
->required() ->required()
->columnSpanFull(), ->columnSpanFull(),
])->columnSpan(2),
Section::make([
TextInput::make('link') TextInput::make('link')
->label('Tautan') ->label('Tautan')
->placeholder('https://www.pwknews.com') ->placeholder('https://www.pwknews.com')
@ -53,9 +55,7 @@ public static function configure(Schema $schema): Schema
->nullable() ->nullable()
->maxLength(255) ->maxLength(255)
->url(), ->url(),
])->columnSpan(2),
Section::make([
Select::make('categories') Select::make('categories')
->label('Kategori') ->label('Kategori')
->relationship('categories', 'name', function (Builder $query): Builder { ->relationship('categories', 'name', function (Builder $query): Builder {
@ -75,7 +75,8 @@ public static function configure(Schema $schema): Schema
$component->state( $component->state(
$record->tags->pluck('name')->toArray() $record->tags->pluck('name')->toArray()
); );
}), })
->helperText('Tekan enter untuk menambahkan tag.'),
Radio::make('status') Radio::make('status')
->label('Status') ->label('Status')

View File

@ -10,6 +10,7 @@
use App\Filament\Actions\Cheerful\RestoreAction; use App\Filament\Actions\Cheerful\RestoreAction;
use App\Filament\Actions\DefaultBulkActions; use App\Filament\Actions\DefaultBulkActions;
use App\Filament\Columns\TimestampColumns; use App\Filament\Columns\TimestampColumns;
use App\Models\News;
use Filament\Actions\BulkActionGroup; use Filament\Actions\BulkActionGroup;
use Filament\Support\Icons\Heroicon; use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn; use Filament\Tables\Columns\TextColumn;
@ -27,13 +28,15 @@ public static function configure(Table $table): Table
->searchable() ->searchable()
->sortable() ->sortable()
->wrap() ->wrap()
->limit(50), ->limit(50)
->description(fn (News $record): string => $record->link),
TextColumn::make('author.name') TextColumn::make('author.name')
->label('Penulis') ->label('Penulis')
->searchable() ->searchable()
->sortable() ->sortable()
->placeholder('Tidak ada'), ->placeholder('Tidak ada'),
TextColumn::make('categories.name') TextColumn::make('categories.name')
->label('Kategori') ->label('Kategori')
->listWithLineBreaks() ->listWithLineBreaks()
@ -50,15 +53,6 @@ public static function configure(Table $table): Table
->badge() ->badge()
->placeholder('Tidak ada tag'), ->placeholder('Tidak ada tag'),
TextColumn::make('link')
->label('Tautan')
->searchable()
->sortable()
->copyable()
->copyMessage('Tautan berhasil disalin')
->placeholder('Tidak ada')
->toggleable(isToggledHiddenByDefault: true),
TextColumn::make('status') TextColumn::make('status')
->label('Status') ->label('Status')
->searchable() ->searchable()
@ -76,8 +70,7 @@ public static function configure(Table $table): Table
->label('Tgl Publish') ->label('Tgl Publish')
->searchable() ->searchable()
->sortable() ->sortable()
->date('l, d F Y H:i') ->date('l, d F Y H:i'),
->toggleable(isToggledHiddenByDefault: true),
...TimestampColumns::make(), ...TimestampColumns::make(),
]) ])