public function actionCreate($id)
 {
     $model = new Province();
     $model->countryId = $id;
     $model->setScenario("create");
     if ($model->load(Yii::$app->request->post(), "Province") && $model->validate()) {
         if (ProvinceService::create($model)) {
             $this->redirect(Url::previous('provinces'));
         }
     }
     return $this->render('create', ['model' => $model, 'returnUrl' => Url::previous('provinces')]);
 }
Example #2
0
 /**
  * @return array - list of Province having all the provinces belonging to this country
  */
 public function getProvinces()
 {
     return $this->hasMany(Province::className(), ['countryId' => 'id']);
 }
Example #3
0
 /**
  * @return Province
  */
 public function getProvince()
 {
     return $this->hasOne(Province::className(), ['id' => 'provinceId']);
 }
Example #4
0
 public static function findById($id)
 {
     return Province::findById($id);
 }