<?php

namespace App\Filament\Resources\Posts\Tables;

use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;

class PostsTable
{
    public static function configure(Table $table): Table
    {
        return $table->defaultSort('published_at', 'desc')->columns([
            TextColumn::make('title')->label('Beitrag')->searchable()->sortable()->description(fn ($record) => $record->category),
            TextColumn::make('excerpt')->label('Kurzbeschreibung')->limit(70)->wrap(),
            IconColumn::make('is_featured')->label('Startseite')->boolean(),
            IconColumn::make('is_published')->label('Online')->boolean(),
            TextColumn::make('published_at')->label('Veröffentlicht')->date('d.m.Y')->sortable(),
        ])->recordActions([EditAction::make()->label('Bearbeiten')]);
    }
}
