56 lines
1.4 KiB
PHP
56 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Device;
|
|
|
|
use App\Entities\Device\LineEntity;
|
|
|
|
class LineModel extends DeviceModel
|
|
{
|
|
const TABLE = "lineinfo";
|
|
const PK = "uid";
|
|
const TITLE = "title";
|
|
protected $table = self::TABLE;
|
|
protected $primaryKey = self::PK;
|
|
protected $returnType = LineEntity::class;
|
|
protected $allowedFields = [
|
|
"clientinfo_uid",
|
|
"status",
|
|
"title",
|
|
"amount",
|
|
];
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function getFilterFields(): array
|
|
{
|
|
return ["clientinfo_uid", 'status'];
|
|
}
|
|
public function getBatchJobFields(): array
|
|
{
|
|
return ['status'];
|
|
}
|
|
public function getFieldRule(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 "amount":
|
|
$rule = "required|numeric";
|
|
break;
|
|
case "title":
|
|
$rule = "required|trim|string";
|
|
break;
|
|
case "status":
|
|
$rule = "required|in_list[in,out]";
|
|
break;
|
|
default:
|
|
$rule = parent::getFieldRule($action, $field);
|
|
break;
|
|
}
|
|
return $rule;
|
|
}
|
|
}
|