예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = League::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'abr', $this->abr]);
     return $dataProvider;
 }
 /**
  * Lists all Tournament models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new TournamentSearch();
     $tournamentTable = $searchModel::tableName();
     $seasonTable = Season::tableName();
     $seasons = Season::find()->innerJoin($tournamentTable, "{$tournamentTable}.season_id = {$seasonTable}.id")->orderBy(['name' => SORT_DESC])->all();
     $availableSeasons = ArrayHelper::map($seasons, 'id', 'name');
     $leagueTable = League::tableName();
     $leagues = League::find()->innerJoin($tournamentTable, "{$tournamentTable}.league_id = {$leagueTable}.id")->all();
     $availableLeagues = ArrayHelper::map($leagues, 'id', 'name');
     $queryParams = Yii::$app->request->queryParams;
     if (count($queryParams) == 0) {
         $queryParams['TournamentSearch']['season_id'] = array_keys($availableSeasons)[0];
     }
     $dataProvider = $searchModel->search($queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'availableSeasons' => $availableSeasons, 'availableLeagues' => $availableLeagues]);
 }
예제 #3
0
}
echo $form->field($model, 'command_id')->widget(SelectizeDropDownList::classname(), ['loadUrl' => Url::to(['team/team-list']), 'items' => $availableTeams, 'options' => ['multiple' => false, 'placeholder' => 'Выберите команду...'], 'clientOptions' => ['valueField' => 'value', 'labelField' => 'text', 'persist' => false]]);
?>
        </div>
        
        <div class="col-sm-6">
        <?php 
echo $form->field($model, 'championship_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Championship::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите чемпионат...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
    </div>
    
    <div class="row">
        <div class="col-sm-6">
        <?php 
echo $form->field($model, 'league_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(League::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите лигу...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
        
        <div class="col-sm-6">
        <?php 
$seasons = ArrayHelper::map(Season::find()->where(['>', 'id', 42])->all(), 'id', 'name');
foreach ($seasons as $key => $season) {
    if (strpos($season, '/') === false) {
        unset($seasons[$key]);
    }
}
echo $form->field($model, 'season_id')->widget(Select2::classname(), ['data' => $seasons, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите сезон...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
    </div>