dbmsv2/app/Models/Customer/ServicePaymentModel.php
2025-08-14 18:36:09 +09:00

66 lines
1.8 KiB
PHP

<?php
namespace App\Models\Customer;
use App\Entities\Customer\ServicePaymentEntity;
use App\Libraries\LogCollector;
class ServicePaymentModel extends CustomerModel
{
const TABLE = "serviceinfo_payment";
const PK = "uid";
const TITLE = "item_type";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = ServicePaymentEntity::class;
protected $allowedFields = [
"serviceinfo_uid",
"ownerinfo_uid",
"user_uid",
"item_type",
"item_uid",
"billing_cycle",
"amount",
"billing_at",
"issue_at",
"status",
"updated_at"
];
public function __construct()
{
parent::__construct();
}
public function getFormFieldRule(string $action, string $field): string
{
if (is_array($field)) {
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
}
switch ($field) {
case "serviceinfo_uid":
case "ownerinfo_uid":
case "item_uid":
case "amount":
$rule = "required|numeric";
break;
case "user_uid":
$rule = "if_exist|numeric";
break;
case "item_type":
case "billing_cycle":
$rule = "required|trim|string";
break;
case "status":
$rule = "if_exist|trim|string";
break;
case "billing_at":
case "issue_at":
$rule = "required|valid_date";
break;
default:
$rule = parent::getFormFieldRule($action, $field);
break;
}
return $rule;
}
}