留学万象
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

71 lines
1.4 KiB

<?php
namespace app\admin\model\wx;
use think\Model;
class Menu extends Model
{
// 表名
protected $name = 'wx_menu';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'integer';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = false;
// 追加属性
protected $append = [
'typedata_text',
'catedata_text'
];
protected static function init()
{
self::afterInsert(function ($row) {
$pk = $row->getPk();
$row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
});
}
public function getTypedataList()
{
return ['0' => __('Typedata 0'), '1' => __('Typedata 1')];
}
public function getCatedataList()
{
return ['0' => __('Catedata 0'), '1' => __('Catedata 1')];
}
public function getTypedataTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['typedata']) ? $data['typedata'] : '');
$list = $this->getTypedataList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getCatedataTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['catedata']) ? $data['catedata'] : '');
$list = $this->getCatedataList();
return isset($list[$value]) ? $list[$value] : '';
}
}