54 lines
1.7 KiB
PHP
54 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer;
|
|
|
|
use App\Entities\Customer\AccountEntity;
|
|
use App\Models\Customer\AccountModel;
|
|
use CodeIgniter\HTTP\IncomingRequest;
|
|
|
|
class AccountService extends CustomerService
|
|
{
|
|
protected ?IncomingRequest $request = null;
|
|
public function __construct(?IncomingRequest $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
}
|
|
final public function getClassName(): string
|
|
{
|
|
return "Account";
|
|
}
|
|
public function getModelClass(): AccountModel
|
|
{
|
|
return new AccountModel();
|
|
}
|
|
public function getEntityClass(): AccountEntity
|
|
{
|
|
return new AccountEntity();
|
|
}
|
|
public function getFormFieldOption(string $field, array $options = []): array
|
|
{
|
|
switch ($field) {
|
|
default:
|
|
$this->getModel()->orderBy($this->getModel()::TITLE, 'ASC');
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
public function create(array $formDatas, mixed $entity = null): AccountEntity
|
|
{
|
|
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
|
|
return parent::create($formDatas, $entity ?? new AccountEntity());
|
|
}
|
|
public function modify(mixed $entity, array $formDatas): AccountEntity
|
|
{
|
|
// die(var_export($formDatas, true));
|
|
//Role을 지정이 있을경우에만 , toggle이나 batcjhjob에서는 없을수도 있으므로
|
|
if (isset($formDatas['role'])) {
|
|
$formDatas['role'] = implode(DEFAULTS["DELIMITER_ROLE"], $formDatas['role']);
|
|
}
|
|
// die(var_export($formDatas, true));
|
|
return parent::modify($entity, $formDatas);
|
|
}
|
|
}
|