<?php namespace app\admin\model\mobile\secret; use think\Model; class SecretSpec extends Model { // 表名 protected $name = 'mobile_secret_spec'; // 自动写入时间戳字段 protected $autoWriteTimestamp = 'int'; // 定义时间戳字段名 protected $createTime = 'createtime'; protected $updateTime = 'updatetime'; protected $deleteTime = false; // 追加属性 protected $append = [ 'is_top_text' ]; public function getIsTopList() { return ['0' => __('Is_top 0'), '1' => __('Is_top 1')]; } public function getIsTopTextAttr($value, $data) { $value = $value ? $value : (isset($data['is_top']) ? $data['is_top'] : ''); $list = $this->getIsTopList(); return isset($list[$value]) ? $list[$value] : ''; } }