/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = PartidaGenerica::find();
     // Join para la relacion
     $query->joinWith(['idPartida']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //Ordenamiento
     $dataProvider->sort->attributes['codigoPartida'] = ['asc' => ['partida_partida.partida' => SORT_ASC], 'desc' => ['partida_partida.partida' => 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, 'id_partida' => $this->id_partida, 'generica' => $this->generica, 'estatus' => $this->estatus]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre]);
     $query->andFilterWhere(['partida_partida.partida' => $this->codigoPartida]);
     return $dataProvider;
 }
Exemple #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPartidasGenericas()
 {
     return $this->hasMany(PartidaGenerica::className(), ['id_partida' => 'id']);
 }
Exemple #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdGenerica()
 {
     return $this->hasOne(PartidaGenerica::className(), ['id' => 'generica']);
 }