From 88c450af7fc8d5d7cbb5b131cf6f6e73b2de91f3 Mon Sep 17 00:00:00 2001 From: Yoga Pangestu Date: Fri, 13 Mar 2026 09:39:39 +0700 Subject: [PATCH] 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. --- .../Resources/Publication/News/NewsResource.php | 7 ------- .../Publication/News/Schemas/NewsForm.php | 7 ++++--- .../Publication/News/Tables/NewsTable.php | 17 +++++------------ 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/app/Filament/Resources/Publication/News/NewsResource.php b/app/Filament/Resources/Publication/News/NewsResource.php index 3e77298..c5354df 100644 --- a/app/Filament/Resources/Publication/News/NewsResource.php +++ b/app/Filament/Resources/Publication/News/NewsResource.php @@ -43,13 +43,6 @@ public static function table(Table $table): Table return NewsTable::configure($table); } - public static function getRelations(): array - { - return [ - // - ]; - } - public static function getPages(): array { return [ diff --git a/app/Filament/Resources/Publication/News/Schemas/NewsForm.php b/app/Filament/Resources/Publication/News/Schemas/NewsForm.php index 770dfde..44247b3 100644 --- a/app/Filament/Resources/Publication/News/Schemas/NewsForm.php +++ b/app/Filament/Resources/Publication/News/Schemas/NewsForm.php @@ -45,7 +45,9 @@ public static function configure(Schema $schema): Schema ->placeholder('...') ->required() ->columnSpanFull(), + ])->columnSpan(2), + Section::make([ TextInput::make('link') ->label('Tautan') ->placeholder('https://www.pwknews.com') @@ -53,9 +55,7 @@ public static function configure(Schema $schema): Schema ->nullable() ->maxLength(255) ->url(), - ])->columnSpan(2), - Section::make([ Select::make('categories') ->label('Kategori') ->relationship('categories', 'name', function (Builder $query): Builder { @@ -75,7 +75,8 @@ public static function configure(Schema $schema): Schema $component->state( $record->tags->pluck('name')->toArray() ); - }), + }) + ->helperText('Tekan enter untuk menambahkan tag.'), Radio::make('status') ->label('Status') diff --git a/app/Filament/Resources/Publication/News/Tables/NewsTable.php b/app/Filament/Resources/Publication/News/Tables/NewsTable.php index 7fd2654..6b8af97 100644 --- a/app/Filament/Resources/Publication/News/Tables/NewsTable.php +++ b/app/Filament/Resources/Publication/News/Tables/NewsTable.php @@ -10,6 +10,7 @@ use App\Filament\Actions\Cheerful\RestoreAction; use App\Filament\Actions\DefaultBulkActions; use App\Filament\Columns\TimestampColumns; +use App\Models\News; use Filament\Actions\BulkActionGroup; use Filament\Support\Icons\Heroicon; use Filament\Tables\Columns\TextColumn; @@ -27,13 +28,15 @@ public static function configure(Table $table): Table ->searchable() ->sortable() ->wrap() - ->limit(50), + ->limit(50) + ->description(fn (News $record): string => $record->link), TextColumn::make('author.name') ->label('Penulis') ->searchable() ->sortable() ->placeholder('Tidak ada'), + TextColumn::make('categories.name') ->label('Kategori') ->listWithLineBreaks() @@ -50,15 +53,6 @@ public static function configure(Table $table): Table ->badge() ->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') ->label('Status') ->searchable() @@ -76,8 +70,7 @@ public static function configure(Table $table): Table ->label('Tgl Publish') ->searchable() ->sortable() - ->date('l, d F Y H:i') - ->toggleable(isToggledHiddenByDefault: true), + ->date('l, d F Y H:i'), ...TimestampColumns::make(), ])