/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Agenda::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['nombre' => SORT_ASC], 'enableMultiSort' => true]]); $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; } // grid filtering conditions $query->andFilterWhere(['numero' => $this->numero]); $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'direccion', $this->direccion])->andFilterWhere(['like', 'localidad', $this->localidad])->andFilterWhere(['like', 'cod_pos', $this->cod_pos])->andFilterWhere(['like', 'provincia', $this->provincia])->andFilterWhere(['like', 'pais', $this->pais])->andFilterWhere(['like', 'telefono', $this->telefono])->andFilterWhere(['like', 'telefono1', $this->telefono1])->andFilterWhere(['like', 'telefono2', $this->telefono2])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'telex', $this->telex])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'palabra', $this->palabra])->andFilterWhere(['like', 'actividad', $this->actividad]); return $dataProvider; }
/** * Finds the Agenda model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Agenda the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Agenda::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }