49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Entities\LoggerEntity;
|
|
|
|
class LoggerModel extends BaseModel
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->table = 'tw_logger';
|
|
$this->allowedFields = [...$this->allowedFields, 'user_uid', 'title', 'content', 'status'];
|
|
$this->validationRules = [
|
|
...$this->validationRules,
|
|
'user_uid' => 'required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]',
|
|
'title' => 'required|string',
|
|
'content' => 'if_exist|string',
|
|
'status' => 'required|string',
|
|
];
|
|
}
|
|
|
|
public function getEntity($uid): LoggerEntity
|
|
{
|
|
$entity = $this->asObject(LoggerEntity::class)->where([$this->primaryKey => $uid])->first();
|
|
return $entity ?: throw new \Exception("{$uid}의 해당 데이터가 없습니다.\n ");
|
|
}
|
|
public function getEntitys($where): array
|
|
{
|
|
return $this->asObject(LoggerEntity::class)->where($where)->findAll();
|
|
}
|
|
public function create(array $formDatas): LoggerEntity
|
|
{
|
|
return $this->create_process(new LoggerEntity(), $formDatas);
|
|
}
|
|
public function modify(LoggerEntity $entity, array $formDatas): LoggerEntity
|
|
{
|
|
return $this->modify_process($entity, $formDatas);
|
|
}
|
|
|
|
//Index관련
|
|
public function setIndexWordFilter(string $word)
|
|
{
|
|
parent::setIndexWordFilter($word);
|
|
$this->orLike('title', $word, 'both');
|
|
$this->orLike('content', $word, 'both'); //befor , after , both
|
|
}
|
|
}
|