65 lines
1.7 KiB
PHP
65 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Customer;
|
|
|
|
use App\Entities\Customer\ServiceEntity;
|
|
|
|
class ServiceModel extends CustomerModel
|
|
{
|
|
const TABLE = "serviceinfo";
|
|
const PK = "uid";
|
|
const TITLE = "uid";
|
|
protected $table = self::TABLE;
|
|
protected $primaryKey = self::PK;
|
|
protected $returnType = ServiceEntity::class;
|
|
protected $allowedFields = [
|
|
"clientinfo_uid",
|
|
"ownerinfo_uid",
|
|
"user_uid",
|
|
"type",
|
|
"location",
|
|
"switch",
|
|
"code",
|
|
"raid",
|
|
"billing_at",
|
|
"start_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 "clientinfo_uid":
|
|
case "ownerinfo_uid":
|
|
case "user_uid":
|
|
$rule = "required|numeric";
|
|
break;
|
|
case "type":
|
|
case "location":
|
|
case "switch":
|
|
case "code":
|
|
case "status":
|
|
$rule = "required|trim|string";
|
|
break;
|
|
case "billing_at":
|
|
case "start_at":
|
|
$rule = "required|valid_date";
|
|
break;
|
|
case "raid":
|
|
$rule = "if_exist|trim|string";
|
|
break;
|
|
default:
|
|
$rule = parent::getFormFieldRule($action, $field);
|
|
break;
|
|
}
|
|
return $rule;
|
|
}
|
|
}
|