40 lines
878 B
PHP
40 lines
878 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class BlockBuilder implements ModelBuilder
|
||
|
|
{
|
||
|
|
|
||
|
|
public function getModelClassName()
|
||
|
|
{
|
||
|
|
return Block::className();
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param array $data
|
||
|
|
* @return ImportRecord
|
||
|
|
*/
|
||
|
|
public function getModel(array $data)
|
||
|
|
{
|
||
|
|
assert('!empty($data)');
|
||
|
|
assert('!empty($data["id"])');
|
||
|
|
$id = (int)$data['id'];
|
||
|
|
$model = Block::findOne($id) ?: new Block;
|
||
|
|
|
||
|
|
$model->id = $id;
|
||
|
|
$model->region_id = (int)$data['region'];
|
||
|
|
$model->builder_id = (int)$data['builderid'];
|
||
|
|
$model->address = $data['address'];
|
||
|
|
$model->name = $data['title'];
|
||
|
|
$model->note = $data['note'];
|
||
|
|
$model->class_id = (int)$data['classid'];
|
||
|
|
|
||
|
|
$model->latitude = Convertor::strToFloat($data['latitude']);
|
||
|
|
$model->longitude = Convertor::strToFloat($data['longitude']);
|
||
|
|
|
||
|
|
if (!empty($data['avatar'])) {
|
||
|
|
$model->image = ImageHelper::getFullUrl($data['avatar']);
|
||
|
|
}
|
||
|
|
|
||
|
|
return $model;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|