vhost/app/Controllers/Admin/CategoryController.php
2024-05-07 18:05:19 +09:00

72 lines
2.1 KiB
PHP

<?php
namespace App\Controllers\Admin;
use App\Models\CategoryModel;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class CategoryController extends AdminController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->_model = new CategoryModel();
$this->_viewDatas['className'] = 'Category';
$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 = [
'uid',
'name',
"linkurl",
"isaccess",
"isread",
"iswrite",
"isreply",
"isupload",
"isdownload",
"status",
"head",
"tail",
];
switch ($action) {
case "index":
case "excel":
return [
'name',
"linkurl",
"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();
}
}