/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProyectoDistribucionPresupuestaria::find();
     // Join para la relacion
     $query->joinWith(['idAccionEspecifica']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //Ordenamiento
     $dataProvider->sort->attributes['nombreAccionEspecifica'] = ['asc' => ['proyecto_accion_especifica.nombre' => SORT_ASC], 'desc' => ['proyecto_accion_especifica.nombre' => 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_accion_especifica' => $this->id_accion_especifica, 'id_partida' => $this->id_partida, 'cantidad' => $this->cantidad]);
     $query->andFilterWhere(['like', 'accion_especifica.nombre', $this->nombreAccionEspecifica]);
     return $dataProvider;
 }
 /**
  * Finds the ProyectoDistribucionPresupuestaria model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return ProyectoDistribucionPresupuestaria the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ProyectoDistribucionPresupuestaria::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }