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'); } }