'if_exist|numeric', 'grporder' => 'if_exist|numeric', 'grpdepth' => 'if_exist|numeric', 'board_config_uid' => 'required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]', 'user_uid' => 'if_exist|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' => 'required|string', 'passwd' => 'if_exist|trim|string', 'view_cnt' => 'if_exist|numeric', 'status' => 'if_exist|string', 'updated_at' => 'if_exist|valid_date', 'created_at' => 'if_exist|valid_date', ]; public function getEntityByField($field, $value): ?BoardEntity { $entity = $this->asObject(BoardEntity::class)->where($field, $value)->first(); if (is_null($entity)) { throw new \Exception("해당 데이터가 없습니다.\n {$field}->{$value}"); } return $entity; } public function getEntity($uid): ?BoardEntity { return $this->getEntityByField($this->primaryKey, $uid); } public function getFieldFormOptions(array $wheres = array(), $temps = array()): array { foreach ($this->asObject(BoardEntity::class)->where($wheres)->findAll() as $entity) { $temps[$entity->getPrimaryKey()] = $entity->getTitle(); } return $temps; } public function create(array $formDatas): BoardEntity { //계층형 Create $entity = $this->create_process(new BoardEntity(), $formDatas); return $this->create_hierarchy($entity); } public function modify(BoardEntity $entity, array $formDatas): BoardEntity { return $this->modify_process($entity, $formDatas); } public function reply(BoardEntity $parent_entity, array $formDatas): BoardEntity { //계층형 Reply $entity = $this->reply_hierarchy(new BoardEntity(), $parent_entity); return $this->create_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 } public function setIndexOrderBy($field, $order = 'DESC') { $this->orderBy("grpno", "DESC"); $this->orderBy("grporder", "ASC"); parent::setIndexOrderBy($field, $order); } }