2024-11-06 19:09:37 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\admin\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 = [
|
2024-11-07 18:11:08 +08:00
|
|
|
'time_text',
|
|
|
|
'jointype_text',
|
|
|
|
'havetype_text'
|
2024-11-06 19:09:37 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-07 18:11:08 +08:00
|
|
|
public function getJointypeList()
|
|
|
|
{
|
|
|
|
return ['1' => __('Jointype 1'), '0' => __('Jointype 0')];
|
|
|
|
}
|
2024-11-06 19:09:37 +08:00
|
|
|
|
2024-11-07 18:11:08 +08:00
|
|
|
public function getHavetypeList()
|
|
|
|
{
|
|
|
|
return ['1' => __('Havetype 1'), '0' => __('Havetype 0')];
|
|
|
|
}
|
2024-11-06 19:09:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2024-11-07 18:11:08 +08:00
|
|
|
|
|
|
|
public function getJointypeTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['jointype']) ? $data['jointype'] : '');
|
|
|
|
$list = $this->getJointypeList();
|
|
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getHavetypeTextAttr($value, $data)
|
|
|
|
{
|
|
|
|
$value = $value ? $value : (isset($data['havetype']) ? $data['havetype'] : '');
|
|
|
|
$list = $this->getHavetypeList();
|
|
|
|
return isset($list[$value]) ? $list[$value] : '';
|
|
|
|
}
|
|
|
|
|
2024-11-06 19:09:37 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|