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.
57 lines
1.3 KiB
57 lines
1.3 KiB
2 years ago
|
<?php
|
||
|
|
||
|
namespace app\admin\model;
|
||
|
|
||
|
use think\Model;
|
||
|
|
||
|
class Third extends Model
|
||
|
{
|
||
|
|
||
|
|
||
|
// 表名
|
||
|
protected $name = 'third';
|
||
|
|
||
|
// 自动写入时间戳字段
|
||
|
protected $autoWriteTimestamp = 'int';
|
||
|
|
||
|
// 定义时间戳字段名
|
||
|
protected $createTime = 'createtime';
|
||
|
protected $updateTime = 'updatetime';
|
||
|
protected $deleteTime = false;
|
||
|
|
||
|
// 追加属性
|
||
|
protected $append = [
|
||
|
'logintime_text',
|
||
|
'expiretime_text'
|
||
|
];
|
||
|
|
||
|
|
||
|
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 getExpiretimeTextAttr($value, $data)
|
||
|
{
|
||
|
$value = $value ? $value : (isset($data['expiretime']) ? $data['expiretime'] : '');
|
||
|
return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
|
||
|
}
|
||
|
|
||
|
protected function setLogintimeAttr($value)
|
||
|
{
|
||
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
}
|
||
|
|
||
|
protected function setExpiretimeAttr($value)
|
||
|
{
|
||
|
return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
|
||
|
}
|
||
|
|
||
|
public function user()
|
||
|
{
|
||
|
return $this->belongsTo("User", 'user_id', 'id')->setEagerlyType(0);
|
||
|
}
|
||
|
}
|