Esempio n. 1
0
 /**
  * Revalidate and/or save postcode
  *
  * @param type $param
  * @return type
  */
 static function check($param = [])
 {
     $country_id = ArrayHelper::getValue($param, 'country_id');
     $postcode = ArrayHelper::getValue($param, 'postcode');
     if ($country_id > 0 && $postcode > 0) {
         $model = static::findNumber($postcode, $country_id);
         if (is_null($model)) {
             $postcode = new RgnPostcode($param);
             return $postcode->save(FALSE) ? $postcode : NULL;
         }
         return $model->improveData($param);
     }
 }
Esempio n. 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRgnPostcodes()
 {
     return $this->hasMany(\common\models\RgnPostcode::className(), ['city_id' => 'id']);
 }
Esempio n. 3
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     $this->operation = new RgnPostcodeOperation(['model' => $this]);
 }