李忠征信平台后端管理系统
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.
 
 
 
 
 
 

62 lines
1.3 KiB

<?php
namespace app\admin\model\content;
use think\Model;
use traits\model\SoftDelete;
use app\admin\model\User;
class Pinglun extends Model
{
use SoftDelete;
// 表名
protected $name = 'content_pinglun';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'datetime';
protected $dateFormat = 'Y-m-d H:i:s';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
// 追加属性
protected $append = [
'status_text',
'avatar',
'username'
];
public function getStatusList()
{
return ['11' => __('Status 11')];
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getAvatarAttr($value, $data)
{
//获取头像
$user = User::get($data['user_id']);
return empty($user)?'':$user['avatar'];
}
public function getUsernameAttr($value, $data)
{
//获取头像
$user = User::get($data['user_id']);
return empty($user)?'用户已注销':$user['nickname'];
}
}