www_fpvone_cn/application/admin/model/fastim/Report.php

84 lines
1.9 KiB
PHP
Raw Normal View History

2024-12-20 12:29:51 +08:00
<?php
namespace app\admin\model\fastim;
use think\Model;
class Report extends Model
{
// 表名
protected $name = 'fastim_report';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'type_text',
'status_text'
];
public function getTypeList()
{
return ['user' => __('Type user'), 'group' => __('Type group'), 'feedback' => __('Type feedback')];
}
public function getStatusList()
{
return ['0' => __('Status 0'), '1' => __('Status 1')];
}
public function getTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
$list = $this->getTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getStatusTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
$list = $this->getStatusList();
return isset($list[$value]) ? $list[$value] : '';
}
/**
* 被举报人
* @return [type] [description]
*/
public function user()
{
return $this->belongsTo('app\admin\model\fastim\User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
/**
* 举报人
* @return [type] [description]
*/
public function reportuser()
{
return $this->belongsTo('app\admin\model\fastim\User', 'report_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
/**
* 被举报群聊
* @return [type] [description]
*/
public function chatgroup()
{
return $this->belongsTo('app\admin\model\fastim\Groupchat', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}