/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Contacts::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, 'client' => $this->client]); $query->andFilterWhere(['like', 'fio', $this->fio])->andFilterWhere(['like', 'dolg', $this->dolg])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Contacts::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(['contact_id' => $this->contact_id, 'datetime' => $this->datetime, 'user_id' => $this->user_id, 'organization_id' => $this->organization_id, 'person_id' => $this->person_id]); $query->andFilterWhere(['like', 'topic', $this->topic])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'result', $this->result])->andFilterWhere(['like', 'result_description', $this->result_description]); return $dataProvider; }
/** * Finds the Contacts model based on its primary key value. * @param integer $id * @return Contacts the loaded model */ protected function findModel($id) { if (($model = Contacts::find()->where(['idContact' => $id])->one()) !== null) { return $model; } else { return false; } }
public function actionStats() { $dataProvider = new ActiveDataProvider(['query' => Contacts::find()->joinWith('organization')->select(['contacts.*', 'count(*) as Count'])->groupBy('organization_id'), 'pagination' => ['pageSize' => 20]]); return $this->render('stats', ['dataProvider' => $dataProvider]); }