User.php
665 字节
<?php
namespace app\api\model;
use think\Model;
class User extends Model
{
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $append = [
'avatar_text',
'invite_time_text'
];
public function getAvatarTextAttr($value,$data)
{
$value = !empty($data['avatar'])?cdnurl($data['avatar'],true):'';
return $value;
}
public function getInviteTimeTextAttr($value,$data)
{
$value = !empty($data['invite_time'])?date('Y/m/d',$data['invite_time']):'';
return $value;
}
}