62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Entities\MyLogEntity as Entity;
|
|
use App\Models\CommonModel;
|
|
|
|
class MyLogModel extends CommonModel
|
|
{
|
|
const TABLE = "logger";
|
|
const PK = "uid";
|
|
const TITLE = "title";
|
|
protected $table = self::TABLE;
|
|
protected $primaryKey = self::PK;
|
|
protected $returnType = Entity::class;
|
|
protected $allowedFields = [
|
|
"user_uid",
|
|
"class_name",
|
|
"method_name",
|
|
"title",
|
|
"content",
|
|
"created_at",
|
|
];
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
public function getFields(): array
|
|
{
|
|
return ['class_name', 'method_name', self::TITLE, 'user_uid', 'status'];
|
|
}
|
|
public function getFilterFields(): array
|
|
{
|
|
return ['user_uid', 'status'];
|
|
}
|
|
public function getBatchJobFields(): array
|
|
{
|
|
return [];
|
|
}
|
|
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 "user_uid":
|
|
$rule = "if_exist|numeric";
|
|
break;
|
|
default:
|
|
$rule = parent::getFieldRule($action, $field);
|
|
break;
|
|
}
|
|
return $rule;
|
|
}
|
|
//List 검색용
|
|
public function setList_WordFilter(string $word): void
|
|
{
|
|
$this->orLike(self::TABLE . "." . self::TITLE, $word, 'both');
|
|
$this->orLike(self::TABLE . '.content', $word, 'both');
|
|
}
|
|
}
|