Ejemplo n.º 1
0
 public function afterSave($insert, $changedAttributes)
 {
     $search = ['language_id' => $this->language_id, 'city_id' => $this->id];
     $model = CityTranslation::findOne($search);
     if (!isset($model)) {
         $model = new CityTranslation($search);
     }
     //Sync from Master
     $model->name = $this->local_name;
     if (!$model->save()) {
         echo 'yaay';
         var_dump($model->errors);
         $this->delete();
         return false;
     }
     return parent::afterSave($insert, $search);
 }
Ejemplo n.º 2
0
 private function _dummyLocation($countryId, $name, $postCode)
 {
     //CityTranslation::find()->where(['language_id' => 'EN', 'name' => $name])->queryScalar();
     $dummyCity = new \humanized\location\models\location\City(['language_id' => 'EN']);
     try {
         $dummyCity->save();
         try {
             $dummyCityTranslation = new \humanized\location\models\translation\CityTranslation(['language_id' => 'EN', 'city_id' => $dummyCity->id, 'name' => $name]);
             $dummyCityTranslation->save();
             try {
                 $dummyLocation = new \humanized\location\models\location\Location(['postcode' => $postCode, 'city_id' => $dummyCity->id, 'country_id' => $countryId]);
                 $dummyLocation->save();
             } catch (Exception $ex) {
             }
         } catch (Exception $ex) {
         }
     } catch (\Exception $ex) {
     }
 }