initModel(new ProductModel()); $this->_viewDatas['className'] = 'Product'; $this->_viewPath .= strtolower($this->_viewDatas['className']); $this->_viewDatas['title'] .= lang($this->_viewDatas['className'] . '.title'); $this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])]; helper($this->_viewDatas['className']); $this->_per_page = 10; } public function getFields(string $action = ""): array { $fields = ["photo", 'user_uid', 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "content",]; switch ($action) { case "index": case "excel": return ["user_uid", 'type', "photo", "cost", "sale", "price", "stock", "view_cnt"]; break; case "view": return ["photo", 'type', 'name', "cost", "sale", "price", "stock", "view_cnt", "created_at", "content"]; break; default: return $fields; break; } } public function getFieldFilters(): array { return ["user_uid", 'type']; } public function getFieldBatchFilters(): array { return parent::getFieldBatchFilters(); } //View관련 protected function view_process($entity) { //Category 확인 $this->setCategory($this->request->getVar('category')); //권한체크 $this->isRole('view'); //조회수 올리기 $entity = $this->getModel()->addViewCount($entity); return parent::view_process($entity); } //Index관련 protected function index_process() { //Category 확인 $this->setCategory($this->request->getVar('category')); //권한체크 $this->isRole('index'); return parent::index_process(); } //Category 및 Status 조건추가 protected function index_condition() { $this->getModel()->where("category", $this->_viewDatas['currentCategory']->getPrimaryKey()); $this->getModel()->where("status", DEFAULTS['STATUS']); parent::index_condition(); } }