table = 'tw_user'; $this->useAutoIncrement = false; $this->allowedFields = [...$this->allowedFields, 'uid', 'id', 'email', 'passwd', 'name', 'role', 'status']; $this->validationRules = [ ...$this->validationRules, 'uid' => 'required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]', 'id' => 'required|min_length[4]|max_length[20]', 'passwd' => 'required|trim|min_length[4]|max_length[150]', 'name' => 'required|min_length[2]|max_length[20]', 'email' => 'required|valid_email', 'role' => 'required|string', 'status' => 'if_exist|string', ]; } public function getEntity($uid): UserEntity { $entity = $this->asObject(UserEntity::class)->where([$this->primaryKey => $uid])->first(); return $entity ?: throw new \Exception("{$uid}의 해당 데이터가 없습니다.\n "); } public function getEntitys($where): array { return $this->asObject(UserEntity::class)->where($where)->findAll(); } public function create(array $formDatas): UserEntity { return $this->create_process(new UserEntity(), $formDatas); } public function modify(UserEntity $entity, array $formDatas): UserEntity { return $this->modify_process($entity, $formDatas); } //Index관련 public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); $this->orLike('id', $word, 'both'); $this->orLike('name', $word, 'both'); //befor , after , both } public function setIndexOrderBy($field, $order = 'ASC') { $this->orderBy("name", "ASC"); parent::setIndexOrderBy($field, $order); } }