/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = LastStatUpdate::find(); $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; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Finds the LastStatUpdate model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return LastStatUpdate the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = LastStatUpdate::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Updates an existing DotaEvent 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'); //echo'<pre>';print_r($_POST);echo'</pre>';die; $model->league_ids = $model->selectedEventLeagues; $model->team_ids = $model->selectedEventTeams; //$model->players_list = DotaPlayer::getActivePlayersList(); if (count($model->team_ids) > 0) { $model->players_list = DotaTeam::getTeamsListWithPlayers($model->team_ids); } else { $model->players_list = []; } //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; $model->heroes_list = DotaHero::getActiveHeroesList(); $model->preparePlayersForEdit(); $model->prepareHeroesForEdit(); /* $rr = DotaEventTeam::find() ->joinWith('team') ->joinWith('') ->where(['event_id'=>$id]) echo'<pre>';print_r($model->dotaEventTeams->joinWith('dotaPlayers'));echo'</pre>';die; */ $dataProviderPlayersStat = DotaEventPlayerStat::searchPlayersStatInEvent($model->id); $dataProviderHeroesStat = DotaEventHeroStat::searchHeroesStatInEvent($model->id); //echo'<pre>';print_r($dataProviderHeroesStat->models);echo'</pre>';die; //echo'<pre>';print_r(DotaTeam::getTeamsListWithPlayers($model->team_ids));echo'</pre>';die; //$model->load(Yii::$app->request->post()); //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; if ($model->load(Yii::$app->request->post()) && $model->validate()) { //if ($model->validate()) { $event = DotaEvent::findOne($model->id); //echo'<pre>';print_r($event->dotaEventPlayerStat);echo'</pre>';die; //echo'<pre>';print_r($model->team_ids);echo'</pre>';die; $model->save(); $DotaEventPlayerStat = Yii::$app->request->post('DotaEventPlayerStat', []); $this->checkPlayersStat($model, $DotaEventPlayerStat); $this->checkLeagues($model); //проверяем изменения в лигах $this->checkTeams($model); //проверяем изменения в командах if (!is_null($model->price_pd) && !is_null($model->price_md_p)) { $this->checkPlayers($model); } //проверяем изменения в игроках if (!is_null($model->price_hd) && !is_null($model->price_md_h)) { $this->checkHeroes($model); } //проверяем изменения в героях Yii::$app->session->setFlash('success', Yii::t('app', 'Saved')); if ($task == 'apply') { return $this->redirect(['update', 'id' => $model->id]); } else { return $this->redirect(['index']); } } else { //echo'<pre>';print_r($model);echo'</pre>';//die; return $this->render('update', ['model' => $model, 'dataProviderPlayersStat' => $dataProviderPlayersStat, 'dataProviderHeroesStat' => $dataProviderHeroesStat, 'last_update_info' => LastStatUpdate::LoadDota()]); } }
/** * @param string $task * @param int $league_key * @param int $match_key * @return array|bool */ public static function updateMatchHistoryAdv($task, $league_key = 0, $match_key = 0) { //$res = true; //echo'<pre>';var_dump($task);echo'</pre>';//die; switch ($task) { case 'updateMatchesResults': $res = self::updateMatchesResultsAdv($league_key, $match_key); break; default: $res = self::updateDotaMatchesPlayersSummaries(); if ($res === true) { $res = self::updateDotaMatchesHeroesSummaries(); } if ($res === true) { $res = self::updateDotaEventPlayerStat(); } if ($res === true) { $res = self::updateDotaEventHeroStat(); } if ($res === true) { $res = self::updateDotaDraftScores(); } if ($res === true) { $res = self::updateDotaDraftPrizes(); } if ($res === true) { $dota_last_update = LastStatUpdate::LoadDota(); $dota_last_update->save(); } break; } return $res; }