DiverseYouthNightSchool/application/common/model/school/classes/VirtualUser.php

61 lines
1.1 KiB
PHP

<?php
namespace app\common\model\school\classes;
use think\Model;
class VirtualUser extends Model
{
// 表名
protected $name = 'school_virtual_user';
// 自动写入时间戳字段
protected $autoWriteTimestamp = false;
// 定义时间戳字段名
protected $createTime = false;
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'time_text'
];
public function getTimeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['time']) ? $data['time'] : '');
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
}
protected function setTimeAttr($value)
{
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
}
public function lib()
{
return $this->belongsTo('Lib', 'classes_lib_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function getHeadImageAttr($value, $data)
{
if (!empty($value)) return cdnurl($value, true);
}
}