48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
class ZipalNewbuildingItemBuilderNew implements ModelBuilder {
|
|
|
|
public function getModel(array $data) {
|
|
assert('!empty($data)');
|
|
assert('!empty($data["id"])');
|
|
$id = $data['id'];
|
|
$model = ZipalNewbuildingItemNew::findOne($id) ?: new ZipalNewbuildingItemNew;
|
|
|
|
$model->id = $id;
|
|
$model->name = $data['name'];
|
|
$model->object_name = $data['object-name'];
|
|
if (!empty($data['housing-name'])) {
|
|
$model->housing_name = $data['housing-name'];
|
|
}
|
|
if (!empty($data['developer-name'])) {
|
|
$model->developer_name = $data['developer-name'];
|
|
}
|
|
if (!empty($data['cian-id'])) {
|
|
$model->cian_id = (int)$data['cian-id'];
|
|
}
|
|
if (!empty($data['cian-korpus-id'])) {
|
|
$model->cian_korpus_id = (int)$data['cian-korpus-id'];
|
|
}
|
|
if (!empty($data['yandex-id'])) {
|
|
$model->yandex_id = (int)$data['yandex-id'];
|
|
}
|
|
if (!empty($data['emls-id'])) {
|
|
$model->emls_id = (int)$data['emls-id'];
|
|
}
|
|
if (!empty($data['avito-object-id'])) {
|
|
$model->avito_object_id = (int)$data['avito-object-id'];
|
|
}
|
|
if (!empty($data['avito-housing-id'])) {
|
|
$model->avito_housing_id = (int)$data['avito-housing-id'];
|
|
}
|
|
$model->region = $data['region'];
|
|
$model->regionKLADRcode = $data['regionKLADRcode'];
|
|
|
|
return $model;
|
|
}
|
|
|
|
public function getModelClassName() {
|
|
return ZipalNewbuildingItemNew::className();
|
|
}
|
|
|
|
} |