コード例 #1
0
 /**
  * Рендерит html регионов для dropdown
  * @param int $id идентификатор страны
  * @throws \yii\base\ExitException
  */
 public function actionRegions($id)
 {
     $all = Region::find()->published()->where(["country_id" => $id])->orderBy(["title" => SORT_ASC])->all();
     $o = ["prompt" => ""];
     echo Html::renderSelectOptions(null, ArrayHelper::map($all, "id", "title"), $o);
     Yii::$app->end();
 }
コード例 #2
0
ファイル: RegionSearch.php プロジェクト: fernandrez/ipcbsas
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Region::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, 'pais_id' => $this->pais_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', 'region_cd', $this->region_cd])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
コード例 #3
0
ファイル: Country.php プロジェクト: frostiks25/rzwebsys7
 /**
  * Связь с регионами
  * @return \yii\db\ActiveQuery
  */
 public function getRegions()
 {
     return $this->hasMany(Region::className(), ["country_id" => "id"])->published();
 }
コード例 #4
0
ファイル: Rajon.php プロジェクト: frostiks25/rzwebsys7
 /**
  * Связь с регионом
  * @return \yii\db\ActiveQuery
  */
 public function getRegion()
 {
     return $this->hasOne(Region::className(), ["id" => "region_id"]);
 }
コード例 #5
0
 public function actionGetCiudadesRegion($region_id, $empty = true)
 {
     if ($empty) {
         $options = ['' => 'Escoge ciudad'];
     }
     $ciudades = Region::find()->where(['id' => $region_id])->one()->ciudads;
     $ciudades = ArrayHelper::map($ciudades, 'id', 'nombre');
     asort($ciudades);
     $options += $ciudades;
     echo Html::renderSelectOptions('', $options);
 }
コード例 #6
0
ファイル: Pais.php プロジェクト: fernandrez/ipcbsas
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegions()
 {
     return $this->hasMany(Region::className(), ['pais_id' => 'id']);
 }
コード例 #7
0
ファイル: Ciudad.php プロジェクト: fernandrez/ipcbsas
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegion()
 {
     return $this->hasOne(Region::className(), ['id' => 'region_id']);
 }
コード例 #8
0
 /**
  * Finds the Region model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Region the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Region::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }