shoppingmallv2/app/Controllers/Admin/BoardController.php
최준흠git config git config --helpgit config --global user.name 최준흠 ebc9e478db shoppingmallv2 init...
2023-08-12 20:55:23 +09:00

66 lines
2.2 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Controllers\Trait\UpDownloadTrait;
use App\Models\BoardModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class BoardController extends AdminController
{
use UpDownloadTrait;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->_model = new BoardModel();
$this->_viewDatas['className'] = 'Board';
$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']);
}
public function getFields(string $action = ""): array
{
$fields = ["category_uid", 'title', "board_file", "passwd", "status", "content"];
switch ($action) {
case "index":
case "excel":
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at"];
break;
case "view":
return ["category_uid", "user_uid", 'title', "board_file", "view_cnt", "status", "created_at", "content"];
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 'board_file':
$file = $this->upload_file_procedure($field);
if (!is_null($file)) {
$this->_viewDatas['fieldDatas'][$field] = $file;
}
break;
default:
return parent::getFieldFormData($field, $entity);
break;
}
return $this->_viewDatas['fieldDatas'];
}
}