shoppingmallv2 init...
This commit is contained in:
parent
e762835675
commit
ee63d7037b
@ -6,16 +6,24 @@ use App\Models\ProductModel;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use App\Models\CategoryModel;
|
||||
|
||||
class ProductController extends FrontController
|
||||
{
|
||||
private $_category = null;
|
||||
private $_categoryModel = null;
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
$this->_model = new ProductModel();
|
||||
$this->_model = new ProductModel($this->getFields());
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->_viewPath .= strtolower($this->_model->getClassName());
|
||||
}
|
||||
|
||||
private function getCategoryModel(): CategoryModel
|
||||
{
|
||||
return $this->_categoryModel = $this->_categoryModel ?: new CategoryModel();
|
||||
}
|
||||
|
||||
public function getFields(string $action = ""): array
|
||||
{
|
||||
$fields = ["category_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",];
|
||||
@ -57,7 +65,42 @@ class ProductController extends FrontController
|
||||
//View관련
|
||||
protected function view_process($entity)
|
||||
{
|
||||
$entity = parent::view_process($entity);
|
||||
return $this->_model->addViewCount($entity);
|
||||
$this->_viewDatas['category'] = $this->getCategoryModel()->getEntity(
|
||||
[$this->getCategoryModel()->getPrimaryKey() => $entity->getCategory_Uid()]
|
||||
);
|
||||
//사용자가 Category에서 해당 게시판의 READ권한이 있는지 확인
|
||||
if (!isRole_CommonHelper(
|
||||
$this->_viewDatas['currentRoles'],
|
||||
$this->_viewDatas['category'],
|
||||
CATEGORY_ROLE_FIELDS['READ']
|
||||
)) {
|
||||
throw new \Exception("고객님은 읽기권한이 없습니다.");
|
||||
}
|
||||
//조회수 올리기
|
||||
$this->_model->addViewCount($entity);
|
||||
return parent::view_process($entity);
|
||||
}
|
||||
|
||||
//Index관련
|
||||
protected function index_process()
|
||||
{
|
||||
$this->_category = $this->request->getVar('category') ?: throw new \Exception("범주를 지정하지 않으셨습니다.");
|
||||
$this->_viewDatas['category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_category]);
|
||||
//사용자가 Category에서 해당 게시판의 ACCESS권한이 있는지 확인
|
||||
if (!isRole_CommonHelper(
|
||||
$this->_viewDatas['currentRoles'],
|
||||
$this->_viewDatas['category'],
|
||||
CATEGORY_ROLE_FIELDS['ACCESS']
|
||||
)) {
|
||||
throw new \Exception("고객님은 접속권한이 없습니다.");
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?= $this->extend('layouts/front') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<div><?= html_entity_decode($viewDatas['category']->getHead()) ?></div>
|
||||
<div class="top">
|
||||
<?= form_open(current_url(), array("method" => "get")) ?>
|
||||
<ul class="nav">
|
||||
@ -32,5 +33,6 @@
|
||||
<?= $viewDatas['pagination'] ?>
|
||||
</div>
|
||||
<?= form_close() ?>
|
||||
<div><?= html_entity_decode($viewDatas['category']->getTail()) ?></div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,6 +1,7 @@
|
||||
<?= $this->extend('layouts/admin') ?>
|
||||
<?= $this->section('content') ?>
|
||||
<div class="content">
|
||||
<div><?= html_entity_decode($viewDatas['category']->getHead()) ?></div>
|
||||
<table class="form table table-bordered table-hover table-striped">
|
||||
<?php foreach ($viewDatas['fields'] as $field) : ?>
|
||||
<tr>
|
||||
@ -19,5 +20,6 @@
|
||||
이제품은 현재[<?= lang('Product.STATUS.' . $entity->getStatus()) ?>]입니다.
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<div><?= html_entity_decode($viewDatas['category']->getTail()) ?></div>
|
||||
</div>
|
||||
<?= $this->endSection() ?>
|
||||
@ -1,16 +1,32 @@
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/order"><?= CLASS_ICONS['ORDER'] ?></i>내주문 보기</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/billing"><?= CLASS_ICONS['BILLING'] ?></i>내결제 보기</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-heading-Life" aria-expanded="false" aria-controls="flush-heading-Life"><b>생활*건강</b></button>
|
||||
</h2>
|
||||
<div id="flush-heading-Life" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-heading-Life">
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-heading-Shoppingmall" aria-expanded="false" aria-controls="flush-heading-Shoppingmall"><b>상점관리</b></button>
|
||||
</h2>
|
||||
<div id="flush-heading-Shoppingmall" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-heading-Shoppingmall">
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/product"><?= CLASS_ICONS['PRODUCT'] ?>상품 보기</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/order"><?= CLASS_ICONS['ORDER'] ?></i>내주문 보기</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/billing"><?= CLASS_ICONS['BILLING'] ?></i>내결제 보기</a></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h2><a href="/front/product?category=5"><?= CLASS_ICONS['PRODUCT'] ?>가구</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/product?category=6"><?= CLASS_ICONS['PRODUCT'] ?>애완동물</a></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2 class="accordion-header">
|
||||
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#flush-heading-Electronic" aria-expanded="false" aria-controls="flush-heading-Electronic"><b>컴퓨터*가전</b></button>
|
||||
</h2>
|
||||
<div id="flush-heading-Electronic" class="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-heading-Electronic">
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/product?category=8"><?= CLASS_ICONS['PRODUCT'] ?>서버장비</a></h2>
|
||||
</div>
|
||||
<div class="accordion-item">
|
||||
<h2><a href="/front/product?category=9"><?= CLASS_ICONS['PRODUCT'] ?>네트워크</a></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user