/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TournamentSettings::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, 'season_id' => $this->season_id, 'scored_missed_weight' => $this->scored_missed_weight, 'goal_scored_weight' => $this->goal_scored_weight, 'goal_missed_weight' => $this->goal_missed_weight, 'win_weight' => $this->win_weight, 'draw_weight' => $this->draw_weight, 'defeat_weight' => $this->defeat_weight]); $query->andFilterWhere(['like', 'cl_positions', $this->cl_positions])->andFilterWhere(['like', 'el_positions', $this->el_positions])->andFilterWhere(['like', 'reduction_positions', $this->reduction_positions]); return $dataProvider; }
/** * Finds the TournamentSettings model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return TournamentSettings the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = TournamentSettings::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @var $this yii\web\View * @var $tournamentData array Array of common\models\Tournament * @var $championshipsData array Array of available championships * @var $seasonsData array Array of available seasons **/ $tournamentTableSettings = TournamentSettings::tableName(); $seasonTable = Season::tableName(); $currentSeason = array_values($seasonsData)[0]; $currentSeasonValue = $currentSeason->value; foreach ($seasonsData as $season) { if ($season->active) { $currentSeasonValue = $season->value; } } $settings = TournamentSettings::find()->where(['season_id' => $currentSeasonValue])->one(); $positions = preg_replace('/\\s+/', '', $settings->cl_positions); $ECLpositionsArray = explode(",", $positions); $positions = preg_replace('/\\s+/', '', $settings->el_positions); $ELpositionsArray = explode(",", $positions); $positions = preg_replace('/\\s+/', '', $settings->reduction_positions); $reductionPositionsArray = explode(",", $positions); $priorityCriteria = []; $count = 0; if (isset($settings->win_weight)) { $priorityCriteria[$count]['value'] = $settings->win_weight; $priorityCriteria[$count]['type'] = "won"; $count++; } if (isset($settings->draw_weight)) { $priorityCriteria[$count]['value'] = $settings->draw_weight;