- payments 表新增 payable_type/payable_id(nullableMorphs),订单可关联文章/套餐等可购买实体 - createOrder 接收 $payable 模型,取代 description 字符串解析 - membership 支付回调按 payable instanceof 分发(激活订阅 / 解锁单篇) - Post/MembershipPlan 提供 payableLabel/payableUrl 约定方法;Payment 用约定方法生成展示标签与后台链接(皮肤等新实体可直接接入) - 订单表格新增「类型」徽章(文章/会员套餐),商品列链接到对应后台编辑页;无 payable 的旧订单显示 —
40 lines
855 B
PHP
40 lines
855 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
namespace Plugins\Neatstudio\Membership\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
class MembershipPlan extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name', 'slug', 'description', 'price', 'duration_days', 'permissions', 'active', 'sort',
|
|
];
|
|
|
|
protected $casts = [
|
|
'permissions' => 'array',
|
|
'active' => 'boolean',
|
|
];
|
|
|
|
public function subscriptions(): HasMany
|
|
{
|
|
return $this->hasMany(Subscription::class);
|
|
}
|
|
|
|
/**
|
|
* 作为可购买实体的展示约定。
|
|
*/
|
|
public function payableLabel(): string
|
|
{
|
|
return '会员套餐:'.$this->name;
|
|
}
|
|
|
|
public function payableUrl(): ?string
|
|
{
|
|
return route('filament.admin.resources.membership-plans.edit', $this);
|
|
}
|
|
}
|