car4s/application/common/model/user4s/Log.php
2022-06-04 17:38:43 +08:00

60 lines
1.1 KiB
PHP

<?php
namespace app\common\model\user4s;
use think\Model;
use traits\model\SoftDelete;
class Log extends Model
{
use SoftDelete;
// 表名
protected $name = 'user4s_log';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = 'deletetime';
// 追加属性
protected $append = [
'state_text'
];
public function getStateList()
{
return ['0' => __('State 0'), '1' => __('State 1')];
}
public function getStateTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
$list = $this->getStateList();
return isset($list[$value]) ? $list[$value] : '';
}
public function user()
{
return $this->belongsTo('User', 'user4s_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
public function admin()
{
return $this->belongsTo('app\common\model\Admin', 'admin_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}