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.
 
 
 
 
 
 

57 lines
1.5 KiB

<?php
namespace app\admin\model\ykjp\system;
use think\Model;
use traits\model\SoftDelete;
class Announcement extends Model {
use SoftDelete;
// 表名
protected $name = 'ykjp_announcement';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
// 追加属性
protected $append = [
'status_text',
'level_text'
];
public function getStatusList() {
return ['0' => __('Status 0'), '1' => __('Status 1')];
}
public function getLevelList() {
return ['紧急' => __('紧急'), '一般' => __('一般')];
}
public function getStatusTextAttr($value, $data) {
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getLevelTextAttr($value, $data) {
$value = $value ? $value : (isset($data['level']) ? $data['level'] : '');
$list = $this->getLevelList();
return isset($list[$value]) ? $list[$value] : '';
}
public function object_array($array) {
if (is_object($array)) {
$array = (array) $array;
} if (is_array($array)) {
foreach ($array as $key => $value) {
$array[$key] = $this->object_array($value);
}
}
return $array;
}
}