/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Messages::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, 'from' => $this->from, 'messageType' => $this->messageType, 'read' => $this->read, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'user_id' => $this->user_id]); $query->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Messages::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, 'datetime' => $this->datetime]); $query->andFilterWhere(['like', 'fio', $this->fio])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text]); $query->orderBy(['datetime' => SORT_DESC]); return $dataProvider; }