chore: 重写初始提交(清空历史,整理后全量提交)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace ywxapp\model;
|
||||
|
||||
use ywxapp\model\BaseModel;
|
||||
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* 站点帮助
|
||||
*/
|
||||
class Help extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $name = 'help';
|
||||
protected $deleteTime = 'delete_at';
|
||||
protected $defaultSoftDelete = 0;
|
||||
|
||||
// 时间戳自动写入
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'create_at';
|
||||
protected $updateTime = 'update_at';
|
||||
|
||||
/**
|
||||
* 运行时自愈:确保 help 主表存在(install.sql 已含 category/view_count 等列,为事实源)。
|
||||
*/
|
||||
public static function ensureSchema(): void
|
||||
{
|
||||
BaseModel::ensureTableFromInstall(BaseModel::currentPrefix(), 'help');
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型初始化时自愈 help 表结构(category / view_count 等扩展列由 install.sql 统一提供)。
|
||||
* 集中在此处,前后台读写共用同一模型,避免各自漏调自愈导致 1054 缺列。
|
||||
*/
|
||||
protected function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
self::ensureSchema();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user