34 lines
826 B
PHP
34 lines
826 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": //ipv4 , ipv6 , both(ipv4,ipv6)
|
|
$rule = sprintf("required|trim|valid_ip[both]%s", 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;
|
|
}
|
|
}
|