104 lines
3.2 KiB
PHP
104 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Controllers\Trait\UpDownloadTrait;
|
|
use App\Models\CategoryModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class CategoryController extends AdminController
|
|
{
|
|
use UpDownloadTrait;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
$this->_model = new CategoryModel();
|
|
parent::initController($request, $response, $logger);
|
|
$this->_viewPath .= strtolower($this->_model->getClassName());
|
|
}
|
|
|
|
public function getFields(string $action = ""): array
|
|
{
|
|
$fields = [
|
|
'name', "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
|
"status", "head", "tail",
|
|
];
|
|
switch ($action) {
|
|
case "index":
|
|
case "excel":
|
|
return [
|
|
'name', 'photo', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
|
|
"status", "created_at"
|
|
];
|
|
break;
|
|
case "view":
|
|
return [...$fields, "updated_at", "created_at"];
|
|
break;
|
|
default:
|
|
return $fields;
|
|
break;
|
|
}
|
|
}
|
|
public function getFieldFilters(): array
|
|
{
|
|
return ["isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status"];
|
|
}
|
|
public function getFieldBatchFilters(): array
|
|
{
|
|
return parent::getFieldBatchFilters();
|
|
}
|
|
//Field별 Form Datas 처리용
|
|
protected function getFieldFormData(string $field, $entity = null): array
|
|
{
|
|
switch ($field) {
|
|
case 'photo':
|
|
$file = $this->upload_image_procedure($field);
|
|
if (!is_null($file)) {
|
|
$this->_viewDatas['fieldDatas'][$field] = $file;
|
|
}
|
|
break;
|
|
default:
|
|
return parent::getFieldFormData($field, $entity);
|
|
break;
|
|
}
|
|
return $this->_viewDatas['fieldDatas'];
|
|
}
|
|
|
|
// private function build_leftmenu()
|
|
// {
|
|
// $categorys = $this->_model->getEntitys(['status' => DEFAULTS['STATUS']]);
|
|
// $leftmenu = view($this->_viewPath . '/leftmenu', ['categorys' => $categorys]);
|
|
// file_put_contents(APPPATH . 'Views' . '/layouts/front/left_menu/leftmenu.php', $leftmenu);
|
|
// }
|
|
|
|
// //Insert관련
|
|
// protected function insert_process()
|
|
// {
|
|
// $entity = parent::insert_process();
|
|
// $this->build_leftmenu();
|
|
// return $entity;
|
|
// }
|
|
// //Update관련
|
|
// protected function update_process($entity)
|
|
// {
|
|
// $entity = parent::update_process($entity);
|
|
// $this->build_leftmenu();
|
|
// return $entity;
|
|
// }
|
|
// //Reply관련
|
|
// protected function reply_process($entity)
|
|
// {
|
|
// $entity = parent::reply_process($entity);
|
|
// $this->build_leftmenu();
|
|
// return $entity;
|
|
// }
|
|
// //Delete 관련
|
|
// protected function delete_process($entity)
|
|
// {
|
|
// $entity = parent::delete_process($entity);
|
|
// $this->build_leftmenu();
|
|
// return $entity;
|
|
// }
|
|
}
|