// +---------------------------------------------------------------------- // +---------------------------------------------------------------------- // | 单页模型 // +---------------------------------------------------------------------- namespace app\admin\model\cms; use think\Model; class Page extends Model { protected $pk = 'catid'; protected $autoWriteTimestamp = true; /** * 根据栏目ID获取内容 * * @param type $catid 栏目ID * * @return boolean */ public function getPage($catid, $cache = false) { if (empty($catid)) { return false; } if (is_numeric($cache)) { $cache = (int) $cache; } return self::get($catid, $cache); } /** * 更新单页内容 * * @param $data * * @return boolean */ public function savePage($data) { if (empty($data)) { $this->error = '内容不能为空!'; return false; } $data['create_time'] = strtotime($data['create_time']); $row = self::get($data['catid']); if ($row) { //更新 self::update($data, [], true); } else { //新增 self::create($data, true); } return true; } }