/** * 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); } }
/** * @return \yii\db\ActiveQuery */ public function getRgnPostcodes() { return $this->hasMany(\common\models\RgnPostcode::className(), ['city_id' => 'id']); }
/** * @inheritdoc */ public function init() { parent::init(); $this->operation = new RgnPostcodeOperation(['model' => $this]); }