dbms/app/Controllers/Admin/MyLogController.php
2025-05-06 10:26:18 +09:00

87 lines
2.6 KiB
PHP

<?php
namespace App\Controllers\Admin;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Services\MyLogService as Service;
use App\Helpers\MyLogHelper as Helper;
use App\Services\UserService;
class MyLogController extends AdminController
{
private $_helper = null;
private $_userService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->uri_path .= strtolower($this->getService()->getClassName()) . '/';
$this->class_path = $this->getService()->getClassPath();
$this->title = lang("{$this->getService()->getClassPath()}.title");
$this->helper = $this->getHelper();
}
final public function getService(): Service
{
if (!$this->_service) {
$this->_service = new Service($this->request);
}
return $this->_service;
}
public function getHelper(): mixed
{
if (!$this->_helper) {
$this->_helper = new Helper($this->request);
}
return $this->_helper;
}
public function getUserService(): UserService
{
if (!$this->_userService) {
$this->_userService = new UserService($this->request);
}
return $this->_userService;
}
//Index,FieldForm관련
public function getFields(): array
{
return ['class_name', 'method_name', $this->getService()->getModel()::TITLE, 'user_uid', 'status'];
}
public function getFilterFields(): array
{
return ['user_uid', 'status'];
}
public function getBatchJobFields(): array
{
return [];
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'user_uid':
$options[$field] = $this->getUserService()->getFormFieldOption($field);
// echo $this->getUserModel()->getLastQuery();
// dd($options);
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//Index,FieldForm관련
//View관련
protected function view_process($uid): mixed
{
$fields = [
'fields' => ['user_uid', 'class_name', 'method_name', $this->getService()->getModel()::TITLE, 'status', 'created_at', 'content'],
];
$this->init('view', $fields);
return parent::view_process($uid);
}
}