public function getPartidaPartida() { if ($this->idGenerica == null) { return null; } return PartidaPartida::find()->where(['id' => $this->idGenerica->id_partida])->one()->partida; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = PartidaPartida::find(); // Join para la relacion $query->joinWith(['cuentaPresupuestaria']); $dataProvider = new ActiveDataProvider(['query' => $query]); //Ordenamiento $dataProvider->sort->attributes['numeroCuenta'] = ['asc' => ['cuenta_presupuestaria.cuenta' => SORT_ASC], 'desc' => ['cuenta_presupuestaria.cuenta' => 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, 'cuenta' => $this->cuenta, 'partida' => $this->partida, 'estatus' => $this->estatus]); $query->andFilterWhere(['like', 'nombre', $this->nombre]); $query->andFilterWhere(['cuenta_presupuestaria.cuenta' => $this->numeroCuenta]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getIdPartida() { return $this->hasOne(PartidaPartida::className(), ['id' => 'id_partida']); }
/** * @return \yii\db\ActiveQuery */ public function getPartidaPartidas() { return $this->hasMany(PartidaPartida::className(), ['cuenta' => 'id']); }