search($where)->field($field)->with($with) ->when($page && $limit, function ($query) use ($page, $limit) { $query->page($page, $limit); })->when(!$page && $limit, function ($query) use ($page, $limit) { $query->limit($limit); })->order('sort desc,id desc')->select()->toArray(); } /** * @param $roomId * @return array|\think\Model|null * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function validRoom($roomId) { return $this->getModel()->where('id', $roomId)->where('status', 'IN', [0, 2])->where('is_del', 0)->find(); } /** * 根据房间ID数组获取直播状态 * @param array $roomIds 房间ID数组 * @return array */ public function getRooms(array $roomIds) { return $this->search(['room_id' => $roomIds])->column('live_status,id', 'room_id'); } }