simedkom/app/Filament/Resources/Publication/News/Tables/NewsTable.php
Yoga Pangestu 2983cd243f refactor: centralize cheerful notifications and cleanup auth calls
- Introduce `CheerfulNotification` utility class to standardize cheerful and expressive notifications across the application.
- Refactor custom "Cheerful" actions (Create, Edit, Delete, etc.) and `DefaultBulkActions` to utilize the new utility class.
- Update all `ToggleColumn` status updates in Master Data modules to use `CheerfulNotification::statusUpdated()`.
- Replace inline `Notification::make()` calls in custom actions (Reply, Crawl News, Cooperation actions) and Resource Pages with `CheerfulNotification` methods.
- Address various lint errors by standardizing the use of the `Auth` facade and improving type hinting for the authenticated `User` model.
2026-01-14 09:54:46 +07:00

104 lines
3.5 KiB
PHP

<?php
namespace App\Filament\Resources\Publication\News\Tables;
use App\Filament\Actions\Cheerful\DeleteAction;
use App\Filament\Actions\Cheerful\EditAction;
use App\Filament\Actions\Cheerful\ForceDeleteAction;
use App\Filament\Actions\Cheerful\RestoreAction;
use App\Filament\Actions\DefaultBulkActions;
use App\Filament\Columns\TimestampColumns;
use Filament\Actions\BulkActionGroup;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\TrashedFilter;
use Filament\Tables\Table;
class NewsTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
TextColumn::make('title')
->label('Judul')
->searchable()
->sortable()
->wrap()
->limit(50),
TextColumn::make('author.name')
->label('Penulis')
->searchable()
->sortable()
->placeholder('Tidak ada'),
TextColumn::make('view')
->label('Dilihat')
->numeric()
->sortable()
->alignCenter(),
TextColumn::make('categories.name')
->label('Kategori')
->listWithLineBreaks()
->limitList(3)
->expandableLimitedList()
->badge()
->placeholder('Tidak ada kategori'),
TextColumn::make('tags.name')
->label('Tag')
->listWithLineBreaks()
->limitList(3)
->expandableLimitedList()
->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()
->sortable()
->badge()
->formatStateUsing(fn (\App\Enums\NewsStatus $state): string => $state->getLabel())
->color(fn (\App\Enums\NewsStatus $state): string => $state->getColor()),
TextColumn::make('published_at')
->label('Tgl Publish')
->searchable()
->sortable()
->date('l, d F Y H:i')
->toggleable(isToggledHiddenByDefault: true),
...TimestampColumns::make(),
])
->filters([
TrashedFilter::make()->native(false),
])
->recordActions([
EditAction::make(),
DeleteAction::make(),
ForceDeleteAction::make(),
RestoreAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
...DefaultBulkActions::make('Berita'),
]),
])
->emptyStateIcon(Heroicon::Newspaper)
->emptyStateDescription('Setelah Anda membuat data pertama, maka akan muncul disini.')
->defaultSort('created_at', 'desc')
->deferFilters(false);
}
}