47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Models\MapurlModel;
|
|
use App\Entities\MapurlEntity;
|
|
|
|
class MapurlService extends CommonService
|
|
{
|
|
private ?MapurlModel $_model = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct("Mapurl", "Mapurl");
|
|
}
|
|
public function getModel(): MapurlModel
|
|
{
|
|
if ($this->_model === null) {
|
|
$this->_model = new MapurlModel();
|
|
}
|
|
return $this->_model;
|
|
}
|
|
public function create(array $formDatas): MapurlEntity
|
|
{
|
|
//생성값 formDatas Log남기기
|
|
foreach ($formDatas as $field => $value) {
|
|
MyLogService::add("info", "{$field}:{$value}");
|
|
}
|
|
return $this->getModel()->create($formDatas);
|
|
}
|
|
public function modify(MapurlEntity $entity, array $formDatas): MapurlEntity
|
|
{
|
|
//변경전 entity 값, 변경값 formDatas Log남기기
|
|
foreach ($this->getModel()->getFields() as $field) {
|
|
MyLogService::add("info", "{$field}:{$entity->$field}=>{$formDatas[$field]}");
|
|
}
|
|
return $this->getModel()->modify($entity, $formDatas);
|
|
}
|
|
public function delete(MapurlEntity $entity): void
|
|
{
|
|
//삭제전 entity 값 Log남기기
|
|
foreach ($this->getModel()->getFields() as $field) {
|
|
MyLogService::add("info", "{$field}:{$entity->$field}");
|
|
}
|
|
$this->getModel()->delete($entity->getPK());
|
|
}
|
|
}
|