_model = new ProductModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewPath .= strtolower($this->_model->getClassName()); } public function getFields(string $action = ""): array { $fields = ["category_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",]; switch ($action) { case "index": case "excel": return ["category_uid", "user_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"]; break; case "view": return [...$fields, "created_at"]; break; default: return $fields; break; } } public function getFieldFilters(): array { return ["category_uid", "user_uid", "status"]; } public function getFieldBatchFilters(): array { return parent::getFieldBatchFilters(); } //Field별 Form Datas 처리용 protected function getFieldFormData(string $field, $entity = null): array { switch ($field) { case 'photo': $this->_viewDatas['fieldDatas'][$field] = $this->single_upload_procedure($field, $entity); break; default: return parent::getFieldFormData($field, $entity); break; } return $this->_viewDatas['fieldDatas']; } //View관련 protected function view_process($entity) { //권한체크 $this->isRole('view', $entity); //조회수 올리기 $this->_model->addViewCount($entity); return parent::view_process($entity); } //Index관련 protected function index_process() { //권한체크 $this->isRole('index'); return parent::index_process(); } //Category 및 Status 조건추가 protected function index_setCondition() { $this->_model->where("category_uid", $this->_viewDatas['category']->getPrimaryKey()); $this->_model->where("status", DEFAULTS['STATUS']); parent::index_setCondition(); } }