示例#1
0
 public function addCountry(AreaAddCountryEvent $event)
 {
     $countryIds = $event->getCountryId();
     $areaId = $event->getAreaId();
     foreach ($countryIds as $countryId) {
         $countryArea = new CountryArea();
         $countryArea->setAreaId($areaId)->setCountryId($countryId)->save();
     }
     $event->setArea(AreaQuery::create()->findPk($areaId));
 }
示例#2
0
 public function addCountry(AreaAddCountryEvent $event)
 {
     $countryIds = $event->getCountryId();
     $areaId = $event->getAreaId();
     foreach ($countryIds as $countryId) {
         $countryArea = new CountryArea();
         $country = explode('-', $countryId);
         if (count($country) === 1) {
             $country[1] = null;
         }
         if ($country[1] == 0) {
             $country[1] = null;
         }
         $countryArea->setAreaId($areaId)->setCountryId($country[0])->setStateId($country[1])->save();
     }
     $event->setArea(AreaQuery::create()->findPk($areaId));
 }