model = new GamePayChannel(); } /** * 获取支付主体 * @return array */ public function getPaySubject() { return Db::connect('db_center')->name('pay_channel')->hidden(['config'])->where('status', 1)->select()->toArray(); } /** * 添加数据 * @param $data * @return mixed */ public function add($data): mixed { $gameId = $data['game_id']; $result =$this->model->where('game_id',$gameId)->select(); if($result->isEmpty()){ $this->model->save($data); }else{ throw new ApiException('该游戏支付渠道已存在'); } return $this->model->getKey(); } }