- 文章列表:会员插件注入「付费」徽章列(会员/付费¥xx,停插件即消失) - 分类:真实文章数(withCount)、名称点击跳文章列表并按分类筛选(ListPosts booted 预置筛选) - 分类:新增封面(medialibrary)+ 介绍(description 字段/表单);前台分类页顶部展示介绍区;SEO description + BreadcrumbList 结构化数据(GEO) - 文章编辑:MarkdownEditor 内容区加大(26rem);文章编辑页新增「评论」关系管理页(可审/拒) - 评论列表:文章列带摘要 - 三套主题补 .category-intro 样式 - 测试更新(付费徽章列)
101 lines
3.6 KiB
PHP
101 lines
3.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
namespace App\Filament\Resources\Posts\Tables;
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Filters\TernaryFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class PostsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->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('category_id')
|
|
->label('分类')
|
|
->relationship('category', 'name'),
|
|
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(),
|
|
])
|
|
->recordUrl(null)
|
|
->recordAction(null)
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->defaultSort('published_at', 'desc');
|
|
}
|
|
}
|