columns([ TextColumn::make('title') ->label('标题') ->searchable() ->limit(40) ->description(fn ($record) => $record->category?->name), TextColumn::make('content_format') ->label('格式') ->badge() ->formatStateUsing(fn ($state) => $state === 'markdown' ? 'MD' : 'HTML') ->color(fn ($state) => $state === 'markdown' ? 'success' : 'gray'), TextColumn::make('status') ->label('状态') ->badge() ->formatStateUsing(fn ($state) => match ($state) { 'published' => '已发布', 'draft' => '草稿', 'private' => '私密', default => $state, }) ->color(fn ($state) => match ($state) { 'published' => 'success', 'draft' => 'warning', default => 'gray', }), IconColumn::make('is_sticky') ->label('置顶') ->boolean(), TextColumn::make('views') ->label('阅读') ->numeric() ->sortable(), TextColumn::make('comment_count') ->label('评论') ->numeric() ->sortable(), TextColumn::make('published_at') ->label('发布时间') ->dateTime('Y-m-d H:i') ->sortable(), ]) ->filters([ SelectFilter::make('status') ->label('状态') ->options([ 'published' => '已发布', 'draft' => '草稿', 'private' => '私密', ]), SelectFilter::make('content_format') ->label('格式') ->options([ 'markdown' => 'Markdown', 'html' => 'HTML', ]), TernaryFilter::make('is_sticky') ->label('置顶'), ], \Filament\Tables\Enums\FiltersLayout::AboveContent) ->filtersFormColumns(3) ->filtersFormWidth(\Filament\Support\Enums\Width::ThreeExtraLarge) ->recordActions([ ViewAction::make(), EditAction::make(), ]) ->toolbarActions([ BulkActionGroup::make([ DeleteBulkAction::make(), ]), ]) ->defaultSort('published_at', 'desc'); } }