Exemplo n.º 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));
 }
Exemplo n.º 2
0
 public function addCountry(AreaAddCountryEvent $event)
 {
     $countryIds = $event->getCountryId();
     $areaId = $event->getAreaId();
     foreach ($countryIds as $countryId) {
         if (null !== ($country = CountryQuery::create()->findPk($countryId))) {
             $country->setDispatcher($event->getDispatcher());
             $country->setAreaId($areaId)->save();
         }
     }
     $event->setArea(AreaQuery::create()->findPk($areaId));
 }
Exemplo n.º 3
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));
 }