<?php namespace app\admin\model; use think\Model; class Activity extends Model { // 表名 protected $name = 'activity'; // 自动写入时间戳字段 protected $autoWriteTimestamp = false; // 定义时间戳字段名 protected $createTime = false; protected $updateTime = false; protected $deleteTime = false; // 追加属性 protected $append = [ 'place_text' ]; public function getPlaceList() { return ['left' => __('Place left'), 'rightTop' => __('Place righttop'), 'rightDown' => __('Place rightdown')]; } public function getPlaceTextAttr($value, $data) { $value = $value ? $value : (isset($data['place']) ? $data['place'] : ''); $list = $this->getPlaceList(); return isset($list[$value]) ? $list[$value] : ''; } }