/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Report::find(); $query->orderBy(['period.year' => SORT_DESC, 'period.month' => SORT_DESC]); $query->with('operator'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false]); $this->load($params); if (!$this->validate()) { $query->where(['1' => false]); return $dataProvider; } if ($this->year !== self::YEAR_ALL) { $query->andWhere(['period.year' => $this->year]); } if ($this->operator !== self::OPERATOR_ALL) { $query->andWhere(['operatorId' => Operator::findOne($this->operator)->getPrimaryKey()]); } return $dataProvider; }