<?php
|
|
|
namespace app\common\model\plus\release;
|
|
use app\common\model\BaseModel;
|
|
/**
|
* 客服消息关系模型
|
*/
|
class ChatRelation extends BaseModel
|
{
|
protected $pk = 'relation_id';
|
protected $name = 'release_chat_relation';
|
|
/**
|
* 关联会员表
|
*/
|
public function user()
|
{
|
return $this->belongsTo('app\\common\\model\\user\\User', 'user_id', 'user_id');
|
}
|
|
/**
|
* 关联会员表
|
*/
|
public function otherUser()
|
{
|
return $this->belongsTo("app\\common\\model\\user\\User", 'user_id', 'other_user_id');
|
}
|
|
/**
|
* 获取关联id
|
*/
|
public static function getRelationId($user_id,$other_user_id)
|
{
|
$model = new static;
|
$data = $model->where("user_id",'=',$user_id)->where("other_user_id",'=',$other_user_id)->find();
|
if(empty($data)){
|
$data = $model->where("other_user_id",'=',$user_id)->where("user_id",'=',$other_user_id)->find();
|
}
|
return empty($data) ? 0 : $data['relation_id'];
|
}
|
}
|