kevin hace 1 año
padre
commit
15f1f17020
Se han modificado 2 ficheros con 7 adiciones y 0 borrados
  1. 1 0
      .gitignore
  2. 6 0
      common/models/forms/ReceiveAddressForm.php

+ 1 - 0
.gitignore

@@ -118,3 +118,4 @@ vendor/yiisoft/yii2/di/Container.php
 vendor/yiisoft/yii2/di/Instance.php
 vendor/yiisoft/yii2/di/NotInstantiableException.php
 vendor/yiisoft/yii2/di/ServiceLocator.php
+frontendApi/runtime/logs/

+ 6 - 0
common/models/forms/ReceiveAddressForm.php

@@ -21,6 +21,7 @@ class ReceiveAddressForm extends Model
     public $id;
     public $consignee;
     public $mobile;
+    public $countryId;
     public $province;
     public $city;
     public $county;
@@ -99,6 +100,7 @@ class ReceiveAddressForm extends Model
                     return $parentResult;
                 }
             }
+
             if ($this->id) {
                 $this->_model = ReceiveAddress::findOne(["ID"=>$this->id]);
                 if (!$this->_model){
@@ -112,6 +114,8 @@ class ReceiveAddressForm extends Model
             } else {
                 $this->_model = new ReceiveAddress();
             }
+
+            $this->countryId = Info::getUserCountryByUserId(\Yii::$app->user->id);
         }
 
         return $parentResult;
@@ -138,6 +142,7 @@ class ReceiveAddressForm extends Model
                 $this->_model->USER_NAME = Info::getUserNameByUserId(\Yii::$app->user->id);
                 $this->_model->CONSIGNEE = $this->consignee;
                 $this->_model->MOBILE = $this->mobile;
+                $this->_model->COUNTRY_ID = $this->countryId ?? Info::getUserCountryByUserId(\Yii::$app->user->id);
                 $this->_model->PROVINCE = $this->province;
                 $this->_model->LGA_NAME = $this->lgaName;
                 $this->_model->CITY_NAME = $this->cityName;
@@ -147,6 +152,7 @@ class ReceiveAddressForm extends Model
             } elseif($this->scenario == 'userEdit') {
                 $this->_model->CONSIGNEE = $this->consignee;
                 $this->_model->MOBILE = $this->mobile;
+                $this->_model->COUNTRY_ID = $this->countryId ?? Info::getUserCountryByUserId(\Yii::$app->user->id);
                 $this->_model->PROVINCE = $this->province;
                 $this->_model->LGA_NAME = $this->lgaName;
                 $this->_model->CITY_NAME = $this->cityName;