dbmsv4/app/Forms/Part/CSForm.php
2025-11-21 17:50:55 +09:00

35 lines
832 B
PHP

<?php
namespace App\Forms\Part;
class CSForm extends PartForm
{
public function __construct()
{
parent::__construct();
}
public function getFormRule(string $action, string $field): string
{
switch ($field) {
case "type":
$rule = "required|trim|string";
break;
case "ip":
$rule = "required|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6)
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
break;
case "accountid":
case "domain":
$rule = "permit_empty|trim|string";
break;
case "status":
$rule = "required|trim|string";
break;
default:
$rule = parent::getFormRule($action, $field);
break;
}
return $rule;
}
}