model = new GameGroup(); $this->gameMainLogic = new GameMainLogic(); } /** * 读取数据 * @param $id * @return mixed */ public function read($id): mixed { $data = $this->model->where('id', $id)->find(); $gameIds = explode(',', $data['game_list']); $gameList = Db::connect('db_center')->table('pf_game')->where("id", $gameIds)->column('name', 'id'); foreach ($gameList as $id => &$name) { $name = '[' . $id . ']' . $name; } $data['game_list_str'] = $gameList; return $data; } /** * 给游戏分组用的游戏列表,主要作用,返回可选或者可编辑的游戏列表 * $where['game_group_id] */ public function getGameListOptionsByGroup($where): array { // Todo 获取非自己的已选中 $gameGroupId = $where['game_group_id']; $data = $this->model->where('id', '<>', $gameGroupId)->column("game_list"); $gameIdList = []; foreach ($data as $gameIds) { $gameIds = explode(',', $gameIds); $gameIdList = array_merge($gameIdList, $gameIds); } // Todo 获取游戏分组 $groupWhere = [ 'status'=>1 ]; if (!empty($gameIdList)) { $groupWhere[] = [ 'id', 'notin', implode(',', $gameIdList)]; } // 平台游戏 $pfCame = Db::connect('db_center')->table('pf_game')->where($groupWhere)->select()->toArray(); return (new GameLogic())->gameMainTree($pfCame); } }