Ejemplo n.º 1
0
 /**
  * Updates an existing Ciudad model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionEditar($id)
 {
     $model = $this->findModel($id);
     $paises = ArrayHelper::map(Pais::find()->where(['lower(status)' => 'activo'])->all(), 'id', 'nombre');
     $regiones = ArrayHelper::map(Region::find()->where(['lower(status)' => 'activo'])->all(), 'id', 'nombre');
     asort($paises);
     asort($regiones);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model, 'paises' => $paises, 'regiones' => $regiones]);
     }
 }
Ejemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Pais::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'pais_cd', $this->pais_cd])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Finds the Pais model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Pais the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Pais::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPais()
 {
     return $this->hasOne(Pais::className(), ['id' => 'pais_id']);
 }
Ejemplo n.º 5
0
 public function actionGetRegionesPais($pais_id, $empty = true)
 {
     if ($empty) {
         $options = ['' => 'Escoge región'];
     }
     $regiones = Pais::find()->where(['id' => $pais_id])->one()->regions;
     $regiones = ArrayHelper::map($regiones, 'id', 'nombre');
     asort($regiones);
     $options += $regiones;
     echo Html::renderSelectOptions('', $options);
 }