/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Cuenta::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, 'fecha_ini' => $this->fecha_ini, 'fecha_fin' => $this->fecha_fin, 'created_at' => $this->created_at, 'baja' => $this->baja, 'id_contacto' => $this->id_contacto, 'id_plan' => $this->id_plan, 'precio' => $this->precio]); $query->andFilterWhere(['like', 'nombre_usuario', $this->nombre_usuario])->andFilterWhere(['like', 'clave', $this->clave]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Cuenta::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); /*$dataProvider->sort->attributes['id'] = [ // The tables are the ones our relation are configured to // in my case they are prefixed with "tbl_" 'asc' => ['id' => SORT_ASC], 'desc' => ['id' => SORT_DESC], ];*/ $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, 'tipocuenta' => $this->tipocuenta, 'saldo' => $this->saldo, 'idconcepto' => $this->idconcepto, 'fecha' => $this->fecha, 'gastoingreso' => $this->gastoingreso]); $query->andFilterWhere(['like', 'descripcion', $this->descripcion]); return $dataProvider; }