/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ContactMoment::find(); $dataProvider = new ActiveDataProvider(['query' => $query->joinWith(['customer', 'creator'])]); $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, 'moment' => $this->moment, 'updater_id' => $this->updater_id, 'datetime_added' => $this->datetime_added, 'datetime_updated' => $this->datetime_updated, 'deleted' => $this->deleted]); $query->andFilterWhere(['like', 'contact_moment.comment', $this->comment])->andFilterWhere(['like', 'user.username', $this->creator_id])->andFilterWhere(['like', 'customer.name', $this->customer_id]); return $dataProvider; }
/** * Lists all ContactMoment models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => ContactMoment::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }