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