dbmsv4/app/Forms/Customer/ServiceForm.php
2025-12-02 12:40:58 +09:00

65 lines
1.8 KiB
PHP

<?php
namespace App\Forms\Customer;
class ServiceForm extends CustomerForm
{
public function __construct()
{
parent::__construct();
}
public function getFormRule(string $action, string $field): string
{
switch ($field) {
case "clientinfo_uid":
case "serverinfo_uid":
case "amount":
case "rack":
case "line":
$rule = "required|numeric";
break;
case "sale":
$rule = "permit_empty|numeric";
break;
case "site":
case "location":
case "status":
$rule = "required|trim|string";
break;
case "billing_at":
case "start_at":
$rule = "required|valid_date";
break;
case "end_at":
$rule = "permit_empty|valid_date";
break;
case 'title':
case "history":
$rule = "permit_empty|trim|string";
break;
default:
$rule = parent::getFormRule($action, $field);
break;
}
return $rule;
}
public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'serverinfo_uid':
foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getCustomTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
$options = parent::getFormOption($action, $field, $formDatas, $options);
break;
}
return $options;
}
}