Files
laralog/app/Filament/Resources/Posts/PostResource.php
T
ak 4f59afb7ce feat: 插件依赖强制校验 + 文章后台表单/表格注入 hook
- PluginManager: requires 依赖链校验(enable 需依赖已启用,disable 阻止有启用依赖者的插件,boot 跳过依赖未满足插件),all() 输出依赖状态供后台展示
- Plugins 页:卡片显示依赖链徽章,依赖未满足时禁用启用按钮,启停失败弹错误通知
- PostResource: form()/table() 增加 filament.post_form / filament.post_table 注入点
- membership 插件:注入「付费设置」Section(meta.price 单篇价格 + meta.members_only 会员专享)与表格价格/会员列
2026-08-12 00:18:40 +08:00

70 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Filament\Resources\Posts;
use App\Filament\Resources\Posts\Pages\CreatePost;
use App\Filament\Resources\Posts\Pages\EditPost;
use App\Filament\Resources\Posts\Pages\ListPosts;
use App\Filament\Resources\Posts\Schemas\PostForm;
use App\Filament\Resources\Posts\Tables\PostsTable;
use App\Models\Post;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
class PostResource extends Resource
{
protected static \UnitEnum|string|null $navigationGroup = '内容';
protected static ?string $navigationLabel = '文章';
protected static ?string $modelLabel = '文章';
protected static ?string $pluralModelLabel = '文章';
protected static ?string $model = Post::class;
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
public static function form(Schema $schema): Schema
{
$schema = PostForm::configure($schema);
// 插件注入:会员付费设置、AI 选项等后台扩展
app(\App\Blog\Support\PluginManager::class)->doAction('filament.post_form', $schema);
return $schema;
}
public static function table(Table $table): Table
{
$table = PostsTable::configure($table);
// 插件注入:价格、会员专享等表格列
app(\App\Blog\Support\PluginManager::class)->doAction('filament.post_table', $table);
return $table;
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => ListPosts::route('/'),
'create' => CreatePost::route('/create'),
'edit' => EditPost::route('/{record}/edit'),
];
}
}