/** * Creates data provider instance with search query applied * * @param array $params * @param boolean $searchPool (-1 Completed, 0 Backlog, otherwise all) * * @return ActiveDataProvider */ public function search($params, $searchPool = null) { switch ($searchPool) { case -1: $query = self::findCompleted(); break; case 0: $query = self::findBacklog(); break; default: $query = self::find(); break; } $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; } // If Create From Date given add to query $query->andFilterWhere(['>=', 'created_at', $this->from_date]); // If Created To Date given add to query $query->andFilterWhere(['<=', 'created_at', $this->to_date]); // If Text search given, search for text in title and description $query->andFilterWhere(['or', ['like', 'title', $this->text_search], ['like', 'description', $this->text_search]]); // If Users selected, restrict ticket search to the selected users (as created by) $query->andFilterWhere(['created_by' => $this->user_search]); if (trim($this->tag_search) != '') { $query->andFilterWhere(['id' => Tags::getTicketId($this->tag_search)]); } return $dataProvider; }