/**
  * Updates an existing PokerEvent model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $task = Yii::$app->request->post('task', 'save');
     $dataProviderPlayersStat = PokerEventPlayerStat::searchPlayersStatInEvent($model->id);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->save();
         if ($task == 'apply') {
             return $this->redirect(['update', 'id' => $model->id]);
         } else {
             return $this->redirect(['index']);
         }
     } else {
         return $this->render('update', ['model' => $model, 'dataProviderPlayersStat' => $dataProviderPlayersStat]);
     }
 }
Exemple #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPokerEventPlayerStats()
 {
     return $this->hasMany(PokerEventPlayerStat::className(), ['account_id' => 'account_id']);
 }
 /**
  * проверяем изменения в очках игроков
  */
 private function checkPlayersStat()
 {
     $PokerEventPlayerStat = Yii::$app->request->post('PokerEventPlayerStat', []);
     //echo'<pre>';print_r($PokerEventPlayerStat);echo'</pre>';die;
     $find = '_corr';
     $event_id = $this->id;
     //echo'<pre>';print_r($event);echo'</pre>';die;
     foreach ($PokerEventPlayerStat as $field => $row) {
         foreach ($row as $account_id => $val) {
             $values = [$field => $val];
             $where = ['event_id = ' . $event_id, 'account_id = ' . $account_id];
             PokerEventPlayerStat::updateRow($values, $where);
         }
     }
 }