45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Customer;
|
|
|
|
use App\Models\CommonModel;
|
|
|
|
abstract class CustomerModel extends CommonModel
|
|
{
|
|
//true이면 모든 delete * 메소드 호출은 실제로 행을 삭제하는 것이 아니라 플래그를 데이터베이스로 설정
|
|
protected $useSoftDeletes = true;
|
|
|
|
protected function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function getFormRule(string $action, string $field): string
|
|
{
|
|
if (is_array($field)) {
|
|
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
|
}
|
|
switch ($field) {
|
|
case "user_uid":
|
|
$rule = "required|numeric";
|
|
break;
|
|
case "clientinfo_uid":
|
|
case "serviceinfo_uid":
|
|
case "serverinfo_uid":
|
|
$rule = "permit_empty|trim|numeric";
|
|
break;
|
|
case "title":
|
|
$rule = "required|trim|string";
|
|
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[" . $this->getTable() . "." . $field . "]" : "";
|
|
break;
|
|
case "status":
|
|
$rule = "permit_empty|trim|string";
|
|
break;
|
|
default:
|
|
$rule = parent::getFormRule($action, $field);
|
|
break;
|
|
}
|
|
return $rule;
|
|
}
|
|
}
|