73 lines
2.0 KiB
PHP
73 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Customer;
|
|
|
|
use App\Entities\Customer\AccountEntity;
|
|
|
|
class AccountModel extends CustomerModel
|
|
{
|
|
const TABLE = "accountinfo";
|
|
const PK = "uid";
|
|
const TITLE = "title";
|
|
protected $table = self::TABLE;
|
|
protected $primaryKey = self::PK;
|
|
protected $returnType = AccountEntity::class;
|
|
protected $allowedFields = [
|
|
"uid",
|
|
"user_uid",
|
|
"clientinfo_uid",
|
|
"bank",
|
|
"title",
|
|
"alias",
|
|
"issue_at",
|
|
"amount",
|
|
"status",
|
|
"updated_at"
|
|
];
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function getFormRule(string $action, string $field): string
|
|
{
|
|
if (is_array($field)) {
|
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
|
}
|
|
switch ($field) {
|
|
case "user_uid":
|
|
case "clientinfo_uid":
|
|
case "amount":
|
|
$rule = "required|numeric";
|
|
break;
|
|
case "bank":
|
|
case "title":
|
|
case "alias":
|
|
case "status":
|
|
$rule = "required|trim|string";
|
|
break;
|
|
case "issue_at":
|
|
$rule = "required|valid_date";
|
|
break;
|
|
default:
|
|
$rule = parent::getFormRule($action, $field);
|
|
break;
|
|
}
|
|
return $rule;
|
|
}
|
|
|
|
final public function create(array $formDatas): AccountEntity
|
|
{
|
|
// 관리자 UID는 현재 인증된 사용자로 설정
|
|
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
|
return parent::create($formDatas);
|
|
}
|
|
//수정
|
|
final public function modify(mixed $entity, array $formDatas): AccountEntity
|
|
{
|
|
// 관리자 UID는 현재 인증된 사용자로 설정
|
|
$formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo();
|
|
// dd($formDatas);
|
|
return parent::modify($entity, $formDatas);
|
|
}
|
|
}
|