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.
58 lines
1.3 KiB
58 lines
1.3 KiB
<?php
|
|
|
|
namespace app\chat\model;
|
|
|
|
use think\model\concern\SoftDelete;
|
|
|
|
class ChatFriendsRoom extends Base
|
|
{
|
|
use SoftDelete;
|
|
|
|
/**
|
|
* 获取聊天室ID
|
|
* @param int $to_user_id 对方user_id
|
|
* @date 2022-08-01
|
|
*/
|
|
public function getFriendsRoomId($to_user_id)
|
|
{
|
|
$where = [
|
|
['uid', '=', $this->mid]
|
|
];
|
|
|
|
return $this->where($where)->where((function ($query) use ($to_user_id) {
|
|
$map1 = [
|
|
['user_id', '=', $this->userId],
|
|
['another_user_id', '=', $to_user_id]
|
|
];
|
|
$map2 = [
|
|
['user_id', '=', $to_user_id],
|
|
['another_user_id', '=', $this->userId]
|
|
];
|
|
$query->whereOr([$map1, $map2]);
|
|
}))->value('id');
|
|
}
|
|
|
|
/**
|
|
* 获取所有相关的room_id
|
|
* @date 2022-09-21
|
|
*/
|
|
public function listRoomId()
|
|
{
|
|
$where = [
|
|
['uid', '=', $this->mid]
|
|
];
|
|
|
|
return $this->where($where)->where((function ($query) {
|
|
$map1 = [
|
|
['user_id', '=', $this->userId]
|
|
];
|
|
$map2 = [
|
|
['another_user_id', '=', $this->userId]
|
|
];
|
|
$query->whereOr([$map1, $map2]);
|
|
}))->column('id');
|
|
}
|
|
|
|
|
|
}
|