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 会员专享)与表格价格/会员列
This commit is contained in:
ak
2026-08-12 00:18:40 +08:00
parent 19fd48213d
commit 4f59afb7ce
8 changed files with 329 additions and 7 deletions
@@ -7,6 +7,13 @@ namespace Plugins\Neatstudio\Membership;
use App\Blog\Support\PluginManager;
use App\Blog\Support\PluginServiceProvider;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Illuminate\Support\Str;
use Plugins\Neatstudio\Membership\Models\MembershipPlan;
use Plugins\Neatstudio\Membership\Models\Subscription;
@@ -75,5 +82,39 @@ class ServiceProvider extends PluginServiceProvider
return $html;
}, 10);
// 后台文章表单注入:付费设置(meta.price 单篇价格 + meta.members_only 会员专享)
$manager->addAction('filament.post_form', function (Schema $schema) {
$schema->components([
...$schema->getComponents(),
Section::make('付费设置')
->description('需启用支付插件并配置支付渠道;0 = 免费')
->columns(3)
->collapsible()
->schema([
TextInput::make('meta.price')
->label('单篇价格(分)')
->numeric()
->minValue(0)
->default(0)
->helperText('例:9900 = ¥99;填 0 表示单篇免费'),
Toggle::make('meta.members_only')
->label('会员专享')
->helperText('整篇文章仅会员可读'),
]),
]);
});
// 后台文章表格注入:价格 / 会员列
$manager->addAction('filament.post_table', function (Table $table) {
$table->pushColumns([
TextColumn::make('meta.price')
->label('单篇价格')
->formatStateUsing(fn ($state) => $state > 0 ? '¥'.number_format((float) $state / 100, 2) : '—'),
IconColumn::make('meta.members_only')
->label('会员')
->boolean(),
]);
});
}
}