dbmsv4/app/Forms/PaymentForm.php
2025-11-20 11:26:53 +09:00

62 lines
1.6 KiB
PHP

<?php
namespace App\Forms;
use App\Forms\CommonForm;
class PaymentForm extends CommonForm
{
public function __construct()
{
parent::__construct();
}
public function getFormRule(string $action, string $field): string
{
switch ($field) {
case "user_uid":
case "clientinfo_uid":
case "serviceinfo_uid":
case "amount":
$rule = "required|numeric";
break;
case "serverpartinfo_uid":
$rule = "permit_empty|numeric";
break;
case "title":
case "billing":
case "pay":
case "status":
$rule = "required|trim|string";
break;
case "billing_at":
$rule = "required|valid_date";
break;
case "content":
$rule = "permit_empty|trim|string";
break;
default:
$rule = parent::getFormRule($action, $field);
break;
}
return $rule;
}
public function getFormOption(string $field, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'serviceinfo_uid':
foreach (service('customer_serviceservice')->getEntities() as $entity) {
$tempOptions[$entity->getPK()] = $entity->getTitle();
// $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
$options = parent::getFormOption($field, $options);
break;
}
return $options;
}
}