73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer;
|
|
|
|
use App\DTOs\Customer\ClientDTO;
|
|
use App\Entities\Customer\ClientEntity;
|
|
use App\Entities\PaymentEntity;
|
|
use App\Forms\Customer\ClientForm;
|
|
use App\Helpers\Customer\ClientHelper;
|
|
use App\Models\Customer\ClientModel;
|
|
use RuntimeException;
|
|
|
|
class ClientService extends CustomerService
|
|
{
|
|
protected string $formClass = ClientForm::class;
|
|
protected string $helperClass = ClientHelper::class;
|
|
|
|
public function __construct(ClientModel $model)
|
|
{
|
|
parent::__construct($model);
|
|
$this->addClassPaths('Client');
|
|
}
|
|
public function getDTOClass(): string
|
|
{
|
|
return ClientDTO::class;
|
|
}
|
|
public function createDTO(array $formDatas): ClientDTO
|
|
{
|
|
return new ClientDTO($formDatas);
|
|
}
|
|
public function getEntityClass(): string
|
|
{
|
|
return ClientEntity::class;
|
|
}
|
|
//기본 기능부분
|
|
protected function getEntity_process(mixed $entity): ClientEntity
|
|
{
|
|
return $entity;
|
|
}
|
|
//List 검색용
|
|
//FormFilter 조건절 처리
|
|
//검색어조건절처리
|
|
//OrderBy 처리
|
|
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
|
{
|
|
$this->model->orderBy("site ASC,name ASC");
|
|
parent::setOrderBy($field, $value);
|
|
}
|
|
|
|
protected function action_process_fieldhook(string $field, $value, array $formDatas): array
|
|
{
|
|
switch ($field) {
|
|
case 'role':
|
|
if (is_string($value)) {
|
|
$value = ($value === '') ? [] : explode(DEFAULTS["DELIMITER_COMMA"], $value);
|
|
} elseif (!is_array($value)) {
|
|
$value = [];
|
|
}
|
|
$value = array_values(array_filter(array_map(
|
|
fn($v) => trim((string) ($v ?? ''), " \t\n\r\0\x0B\""),
|
|
$value
|
|
)));
|
|
$formDatas[$field] = $value;
|
|
break;
|
|
default:
|
|
$formDatas = parent::action_process_fieldhook($field, $value, $formDatas);
|
|
break;
|
|
}
|
|
return $formDatas;
|
|
}
|
|
|
|
}
|