示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PokerPlayer::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['account_id' => $this->account_id, 'status' => $this->status, 'country_id' => $this->country_id]);
     $query->andFilterWhere(['like', 'personaname', $this->personaname])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'middlename', $this->middlename])->andFilterWhere(['like', 'foto', $this->foto])->andFilterWhere(['like', 'comment', $this->comment])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
示例#2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPlayer()
 {
     return $this->hasOne(PokerPlayer::className(), ['account_id' => 'account_id']);
 }
示例#3
0
 /**
  * проверяем изменения в игроках
  */
 private function checkPlayers()
 {
     $player = new PokerPlayer();
     $players_in_draft = $player->getPresentedPlayersInDrafts($this->id);
     //echo'<pre>';print_r($players_in_draft);echo'</pre>';die;
     //echo'<pre>';print_r($player->fantasyTableName);echo'</pre>';die;
     $array_identical = false;
     //echo'<pre>';print_r($this->pokerEventPlayerStats);echo'</pre>';//die;
     //echo'<pre>';print_r($this->player_id);echo'</pre>';die;
     if (count($this->eventPlayers) != count($this->player_id)) {
         $array_identical = false;
     } else {
         foreach ($this->eventPlayers as $model1) {
             $array_identical = false;
             foreach ($this->player_id as $value) {
                 $array_identical = false;
                 if ($model1->account_id == $value) {
                     if ($this->price[$model1->account_id] == $model1->price) {
                         $array_identical = true;
                     } else {
                         $array_identical = false;
                     }
                 }
                 if ($array_identical === false) {
                     break;
                 }
             }
             if ($array_identical === false) {
                 break;
             }
         }
     }
     if ($array_identical == false) {
         /*
         SELECT DISTINCT(pdp.`account_id`)
         FROM `0af_poker_draft_player` AS pdp
         INNER JOIN `0af_poker_draft` AS pd ON pd.id = pdp.draft_id
         WHERE pd.fantasy_id IN(2,3)
         */
         foreach ($this->eventPlayers as $model1) {
             //echo'<pre>';print_r($model1);echo'</pre>';die;
             if (!isset($players_in_draft[$model1->account_id])) {
                 $model1->delete();
             }
         }
         foreach ($this->player_id as $player_id) {
             if (!isset($players_in_draft[$player_id])) {
                 if ($this->price[$player_id] != 0) {
                     $model_n = new PokerEventPlayer();
                     $model_n->event_id = $this->id;
                     $model_n->account_id = $player_id;
                     $model_n->price = $this->price[$player_id];
                     $model_n->save();
                     // проверяем игроков в статистике. Если такой отсутствует - добавляем.
                     $present = false;
                     foreach ($this->eventPlayerStats as $pokerEventPlayerStat) {
                         if ($pokerEventPlayerStat->account_id == $player_id) {
                             $present = true;
                         }
                     }
                     if ($present === false) {
                         $model_n = new PokerEventPlayerStat();
                         $model_n->account_id = $player_id;
                         $model_n->event_id = $this->id;
                         $model_n->scores = 0;
                         $model_n->save();
                     }
                 } else {
                     // если игрока убрали из ивента - удаляем по нему запись о его статистике
                     foreach ($this->eventPlayerStats as $pokerEventPlayerStat) {
                         if ($pokerEventPlayerStat->account_id == $player_id) {
                             $pokerEventPlayerStat->delete();
                         }
                     }
                 }
             }
         }
     }
 }
示例#4
0
 /**
  * возвращает информацию по игрокам на которых была сделана ставка
  *
  * @return \yii\db\ActiveQuery
  */
 public function getDraftPlayersInfo()
 {
     return $this->hasMany(PokerPlayer::className(), ['account_id' => 'account_id'])->viaTable('{{%poker_draft_player}}', ['draft_id' => 'id']);
 }