109 lines
3.2 KiB
PHP
109 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin;
|
|
|
|
use App\Models\LoggerModel;
|
|
use App\Models\UserModel;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class LoggerController extends \App\Controllers\Admin\AdminController
|
|
{
|
|
private $_userModel = null;
|
|
private $_user_uids = null;
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
$this->_className .= '/Logger';
|
|
$this->_model = new LoggerModel();
|
|
$this->_defines = [
|
|
'view' => [
|
|
'fields' => ['user_uid', 'title', 'content', 'status', 'created_at'],
|
|
'fieldFilters' => ['user_uid', 'status'],
|
|
'fieldRules' => [],
|
|
],
|
|
'index' => [
|
|
'fields' => ['user_uid', 'title', 'status', 'created_at'],
|
|
'fieldFilters' => ['user_uid', 'status'],
|
|
'batchjobFilters' => [],
|
|
],
|
|
'excel' => [
|
|
'fields' => ['user_uid', 'title', 'status', 'created_at'],
|
|
'fieldFilters' => ['user_uid', 'status'],
|
|
],
|
|
];
|
|
helper($this->_className);
|
|
$this->_viewPath = strtolower($this->_className);
|
|
$this->_viewDatas['title'] = lang($this->_className . '.title');
|
|
$this->_viewDatas['className'] = $this->_className;
|
|
}
|
|
|
|
private function getUserModel(): UserModel
|
|
{
|
|
return is_null($this->_userModel) ? new UserModel() : $this->_userModel;
|
|
}
|
|
|
|
//Field별 Form Option용
|
|
protected function getFieldFormOption(string $field): array
|
|
{
|
|
switch ($field) {
|
|
case 'user_uid':
|
|
if (is_null($this->_user_uids)) {
|
|
//모든 필요한 FormOption등 조기화작업 필요
|
|
$this->_user_uids = $this->getUserModel()->getList(
|
|
['status' => 'use'],
|
|
[DEFAULTS['EMPTY'] => lang($this->_className . '.label.' . $field) . ' 선택']
|
|
);
|
|
}
|
|
return $this->_user_uids;
|
|
break;
|
|
default:
|
|
return parent::getFieldFormOption($field);
|
|
break;
|
|
}
|
|
}
|
|
|
|
////Action 모음
|
|
//Insert관련
|
|
final public function insert()
|
|
{
|
|
return $this->insert_procedure();
|
|
}
|
|
//Update관련
|
|
final public function update($uid)
|
|
{
|
|
return $this->update_procedure($uid);
|
|
}
|
|
//Toggle관련
|
|
final public function toggle($uid, string $field)
|
|
{
|
|
return $this->toggle_procedure($uid, $field);
|
|
}
|
|
//Batchjob 관련
|
|
// final public function batchjob()
|
|
// {
|
|
// return $this->batchjob_procedure();
|
|
// }
|
|
//Delete 관련
|
|
// final public function delete($uid)
|
|
// {
|
|
// return $this->delete_procedure($uid);
|
|
// }
|
|
//View 관련
|
|
final public function view($uid)
|
|
{
|
|
return $this->view_procedure($uid);
|
|
}
|
|
//Index 관련
|
|
final public function index()
|
|
{
|
|
return $this->index_procedure();
|
|
}
|
|
//Excel 관련
|
|
final public function excel()
|
|
{
|
|
return $this->excel_procedure();
|
|
}
|
|
}
|