- 文章列表:会员插件注入「付费」徽章列(会员/付费¥xx,停插件即消失) - 分类:真实文章数(withCount)、名称点击跳文章列表并按分类筛选(ListPosts booted 预置筛选) - 分类:新增封面(medialibrary)+ 介绍(description 字段/表单);前台分类页顶部展示介绍区;SEO description + BreadcrumbList 结构化数据(GEO) - 文章编辑:MarkdownEditor 内容区加大(26rem);文章编辑页新增「评论」关系管理页(可审/拒) - 评论列表:文章列带摘要 - 三套主题补 .category-intro 样式 - 测试更新(付费徽章列)
98 lines
3.7 KiB
PHP
98 lines
3.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
namespace App\Filament\Resources\Comments\Tables;
|
|
|
|
use App\Models\Comment;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class CommentsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('author_name')
|
|
->label('作者')
|
|
->searchable()
|
|
->weight('bold'),
|
|
TextColumn::make('content')
|
|
->label('内容')
|
|
->limit(60)
|
|
->searchable(),
|
|
TextColumn::make('post.title')
|
|
->label('文章')
|
|
->limit(30)
|
|
->description(fn ($record) => $record->post ? \Illuminate\Support\Str::limit($record->post->excerpt_or_fallback, 50) : null)
|
|
->url(fn ($record) => $record->post ? route('posts.show', $record->post->slug ?: $record->post->id) : null)
|
|
->openUrlInNewTab(),
|
|
TextColumn::make('status')
|
|
->label('状态')
|
|
->badge()
|
|
->formatStateUsing(fn ($state) => match ($state) {
|
|
'published' => '已发布',
|
|
'pending' => '待审核',
|
|
'spam' => '垃圾',
|
|
'rejected' => '已拒绝',
|
|
default => $state,
|
|
})
|
|
->color(fn ($state) => match ($state) {
|
|
'published' => 'success',
|
|
'pending' => 'warning',
|
|
'spam' => 'danger',
|
|
default => 'gray',
|
|
}),
|
|
TextColumn::make('ip')
|
|
->label('IP'),
|
|
TextColumn::make('created_at')
|
|
->label('时间')
|
|
->dateTime('Y-m-d H:i')
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('status')
|
|
->label('状态')
|
|
->options([
|
|
'published' => '已发布',
|
|
'pending' => '待审核',
|
|
'spam' => '垃圾',
|
|
'rejected' => '已拒绝',
|
|
]),
|
|
], \Filament\Tables\Enums\FiltersLayout::AboveContent)
|
|
->recordActions([
|
|
Action::make('approve')
|
|
->label('通过')
|
|
->icon('heroicon-o-check')
|
|
->color('success')
|
|
->visible(fn (Comment $record) => $record->status !== 'published')
|
|
->action(function (Comment $record): void {
|
|
$record->update(['status' => 'published'])
|
|
->recordUrl(null)
|
|
->recordAction(null);
|
|
$record->post?->increment('comment_count');
|
|
}),
|
|
Action::make('spam')
|
|
->label('垃圾')
|
|
->icon('heroicon-o-x-mark')
|
|
->color('danger')
|
|
->visible(fn (Comment $record) => $record->status !== 'spam')
|
|
->action(fn (Comment $record) => $record->update(['status' => 'spam'])),
|
|
EditAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
}
|