Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $fantasy_type = 'all', $only_active = true)
 {
     $query = DotaFantasy::find()->joinWith('event');
     $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, 'event_id' => $this->event_id, 'draft_id' => $this->draft_id, 'users_count' => $this->users_count, 'deposit' => $this->deposit, 'prize_pool' => $this->prize_pool]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     switch ($fantasy_type) {
         case self::FANTASY_LIST_NOW:
             $query->andFilterWhere(['<', 'start', time()]);
             $query->andFilterWhere(['>', 'end', time()]);
             break;
         case self::FANTASY_LIST_FUTURE:
             $query->andFilterWhere(['>', 'start', time()]);
             break;
     }
     if ($only_active == true) {
         $query->andFilterWhere(['=', 'status', self::FANTASY_ACTIVE]);
     }
     return $dataProvider;
 }
Пример #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DotaFantasy::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'event_id' => $this->event_id, 'users_count' => $this->users_count, 'deposit' => $this->deposit, 'prize_pool' => $this->prize_pool]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }