88 lines
2.1 KiB
PHP
88 lines
2.1 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace app\manystore\model\user;
|
||
|
|
||
|
use think\Model;
|
||
|
|
||
|
|
||
|
class User extends Model
|
||
|
{
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
// 表名
|
||
|
protected $name = 'user';
|
||
|
|
||
|
// 自动写入时间戳字段
|
||
|
protected $autoWriteTimestamp = 'int';
|
||
|
|
||
|
// 定义时间戳字段名
|
||
|
protected $createTime = 'createtime';
|
||
|
protected $updateTime = 'updatetime';
|
||
|
protected $deleteTime = false;
|
||
|
|
||
|
// 追加属性
|
||
|
protected $append = [
|
||
|
'prevtime_text',
|
||
|
'logintime_text',
|
||
|
'loginfailuretime_text',
|
||
|
'jointime_text'
|
||
|
];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
public function getPrevtimeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['prevtime']) ? $data['prevtime'] : '');
|
||
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getLogintimeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['logintime']) ? $data['logintime'] : '');
|
||
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getLoginfailuretimeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['loginfailuretime']) ? $data['loginfailuretime'] : '');
|
||
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||
|
}
|
||
|
|
||
|
|
||
|
public function getJointimeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['jointime']) ? $data['jointime'] : '');
|
||
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||
|
}
|
||
|
|
||
|
protected function setPrevtimeAttr($value)
|
||
|
{
|
||
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
}
|
||
|
|
||
|
protected function setLogintimeAttr($value)
|
||
|
{
|
||
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
}
|
||
|
|
||
|
protected function setLoginfailuretimeAttr($value)
|
||
|
{
|
||
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
}
|
||
|
|
||
|
protected function setJointimeAttr($value)
|
||
|
{
|
||
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|