// +---------------------------------------------------------------------- declare(strict_types=1); namespace app\appmall\model; use app\appmall\library\AppmallSchema; use ywxapp\model\BaseModel; /** * 市场客户端站点(中心站,授权绑定维度,对齐 Discuz!「授权绑定站点域名」) * 表:appmall_sites * @mixin \think\Model */ class Site extends BaseModel { protected function getOptions(): array { return [ 'strict' => true, 'name' => 'appmall_sites', 'autoWriteTimestamp' => 'int', 'createTime' => 'create_at', 'updateTime' => 'update_at', ]; } /** * 表结构自愈:缺表建表(事实源 app/appmall/install.sql)。 */ public static function ensureSchema(): void { AppmallSchema::ensureTable('appmall_sites'); } /** * 模型一被使用(含静态查询)就先兜底建表,任何入口都不会再撞 1146。 */ protected function initialize() { parent::initialize(); self::ensureSchema(); } /** * 关联站点下的授权(appmall_addon_licenses) * @return \think\model\relation\HasMany */ public function licenses() { return $this->hasMany(AddonLicense::class, 'site_id', 'id'); } }