/** * @return \yii\db\ActiveQuery */ public function createCityAndAddress($modelPlaceRegion, $cityPlaceId, $addressPlaceId) { $modelPlaceAddress = new PlaceAddress(); $modelPlaceAddress->place_id = $addressPlaceId; $modelPlaceCity = new PlaceCity(); $modelPlaceCity->place_id = $cityPlaceId; $modelPlaceCity->link('region', $modelPlaceRegion); $modelPlaceCity->link('placeAddresses', $modelPlaceAddress); return $modelPlaceAddress; }
/** * @return \yii\db\ActiveQuery */ public function createRegionAndCityAndAddress($modelPlaceCountry, $regionPlaceId, $cityPlaceId, $addressPlaceId) { $modelPlaceRegion = new PlaceRegion(); $modelPlaceRegion->place_id = $regionPlaceId; $modelPlaceRegion->link('country', $modelPlaceCountry); $modelPlaceCity = new PlaceCity(); $modelPlaceCity->place_id = $cityPlaceId; $modelPlaceCity->link('region', $modelPlaceRegion); $modelPlaceAddress = new PlaceAddress(); $modelPlaceAddress->place_id = $addressPlaceId; $modelPlaceAddress->city_id = $modelPlaceCity->id; return $modelPlaceAddress->save() ? $modelPlaceAddress : false; }