<?php namespace app\admin\model\mobile; use think\Model; class SimulationQuestion extends Model { // 表名 protected $name = 'mobile_question'; // 自动写入时间戳字段 protected $autoWriteTimestamp = 'int'; // 定义时间戳字段名 protected $createTime = 'createtime'; protected $updateTime = 'updatetime'; protected $deleteTime = false; // 追加属性 protected $append = [ 'target_type_text', 'type_text' ]; public function getTargetTypeList() { return ['1' => __('Target_type 1'), '2' => __('Target_type 2'), '3' => __('Target_type 3'), '4' => __('Target_type 4'), '5' => __('Target_type 5')]; } public function getTypeList() { return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')]; } public function getTargetTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['target_type']) ? $data['target_type'] : ''); $list = $this->getTargetTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['type']) ? $data['type'] : ''); $list = $this->getTypeList(); return isset($list[$value]) ? $list[$value] : ''; } }