allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$fields]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } final public function getTitleField(): string { return 'product_uid'; } protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { case $this->getTitleField(): $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; break; break; case 'quantity': case 'price': $rules[$field] = "required|numeric"; break; default: $rules = parent::getFieldRule($field, $rules, $action); break; } return $rules; } //Field별 Form Option용 public function getFieldFormOption(string $field): array { switch ($field) { case 'product_uid': if (is_null($this->_product_options)) { $productModel = new productModel([$this->getPrimaryKey(), 'product_uid']); $this->_product_options = $productModel->getOptions(); } $options = $this->_product_options; break; default: return parent::getFieldFormOption($field); break; } if (!is_array($options)) { throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); } return $options; } public function getEntity($conditions): OrderEntity { return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true)); } //장바구니에 넣기 public function create(array $formDatas): OrderEntity { return $this->create_process(new OrderEntity(), $formDatas); } public function modify(OrderEntity $entity, array $formDatas): OrderEntity { return $this->modify_process($entity, $formDatas); } //Index관련 public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); $this->orLike($this->getTitleField(), $word, "both"); } }