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

87 lines
2.2 KiB
PHP
Raw Normal View History

2024-12-20 12:29:51 +08:00
<?php
namespace app\admin\model\fastim;
use think\Model;
class Groupchat extends Model
{
// 表名
protected $name = 'fastim_group_chat';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = false;
protected $deleteTime = false;
// 追加属性
protected $append = [
'add_mode_text',
'invite_join_group_text',
'speak_text',
'history_message_text'
];
public function getAddModeList()
{
return ['0' => __('Add_mode 0'), '1' => __('Add_mode 1')];
}
public function getInviteJoinGroupList()
{
return ['0' => __('Invite_join_group 0'), '1' => __('Invite_join_group 1')];
}
public function getSpeakList()
{
return ['0' => __('Speak 0'), '1' => __('Speak 1')];
}
public function getHistoryMessageList()
{
return ['0' => __('History_message 0'), '1' => __('History_message 1')];
}
public function getAddModeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['add_mode']) ? $data['add_mode'] : '');
$list = $this->getAddModeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getInviteJoinGroupTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['invite_join_group']) ? $data['invite_join_group'] : '');
$list = $this->getInviteJoinGroupList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getSpeakTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['speak']) ? $data['speak'] : '');
$list = $this->getSpeakList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getHistoryMessageTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['history_message']) ? $data['history_message'] : '');
$list = $this->getHistoryMessageList();
return isset($list[$value]) ? $list[$value] : '';
}
public function fastimuser()
{
return $this->belongsTo('app\admin\model\fastim\User', 'leader', 'id', [], 'LEFT')->setEagerlyType(0);
}
}