// +---------------------------------------------------------------------- namespace ywxapp\model; /** * Configure 类 * * @author ywxapp */ class CommonConfigure extends BaseModel { protected function getOptions(): array { return [ 'strict' => false, 'autoWriteTimestamp' => 'int', 'createTime' => 'create_at', 'updateTime' => 'update_at', 'deleteTime' => 'delete_at', 'defaultSoftDelete' => 0, 'append' => ['target'], 'hidden' => ['create_at', 'update_at', 'delete_at'], 'readonly' => ['id'], ]; } public function getTitleAttr($value) { return lang($value); } public function getGroupAttr($value) { return lang($value); } /** * 运行时自愈:确保 configure 主表存在(install.sql 为事实源)。 */ public static function ensureSchema(): void { BaseModel::ensureTableFromInstall(BaseModel::currentPrefix(), 'common_configure'); } /** * 初始化:自愈建表,避免远程库缺失 wxapp_configure 导致 1146。 */ protected function initialize() { parent::initialize(); self::ensureSchema(); } }