vhost init...2

This commit is contained in:
최준흠 2024-05-14 09:48:09 +09:00
parent c0400c1433
commit 229e7e0fa9
4 changed files with 22 additions and 38 deletions

View File

@ -13,43 +13,27 @@ class CategoryController extends AdminController
{ {
parent::initController($request, $response, $logger); parent::initController($request, $response, $logger);
$this->_model = new CategoryModel(); $this->_model = new CategoryModel();
$this->_viewDatas['className'] = 'Category'; $this->_viewDatas["className"] = "Category";
$this->_viewPath .= strtolower($this->_viewDatas['className']); $this->_viewPath .= strtolower($this->_viewDatas["className"]);
$this->_viewDatas['title'] = lang($this->_viewDatas['className'] . '.title'); $this->_viewDatas["title"] = lang($this->_viewDatas["className"] . ".title");
$this->_viewDatas['class_icon'] = CLASS_ICONS[strtoupper($this->_viewDatas['className'])]; $this->_viewDatas["class_icon"] = CLASS_ICONS[strtoupper($this->_viewDatas["className"])];
helper($this->_viewDatas['className']); helper($this->_viewDatas["className"]);
} }
public function getFields(string $action = ""): array public function getFields(string $action = ""): array
{ {
$fields = [ $fields = [
'uid', "uid", "name", "linkurl",
'name', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"linkurl", "status", "head", "tail",
"isaccess",
"isread",
"iswrite",
"isreply",
"isupload",
"isdownload",
"status",
"head",
"tail",
]; ];
switch ($action) { switch ($action) {
case "index": case "index":
case "excel": case "excel":
return [ return [
'name', "name", "linkurl",
"linkurl", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"isaccess", "status", "created_at",
"isread",
"iswrite",
"isreply",
"isupload",
"isdownload",
"status",
"created_at",
]; ];
break; break;
case "view": case "view":

View File

@ -8,9 +8,9 @@ return [
'title' => "분류 정보", 'title' => "분류 정보",
'label' => [ 'label' => [
'uid' => "분류코드", 'uid' => "분류코드",
'linkurl' => "연결URL",
'parent' => "상단코드", 'parent' => "상단코드",
'name' => "분류제목", 'name' => "분류제목",
'linkurl' => "LinkURL",
'photo' => "이미지", 'photo' => "이미지",
'isaccess' => "접속권한", 'isaccess' => "접속권한",
'isread' => "읽기권한", 'isread' => "읽기권한",

View File

@ -180,7 +180,7 @@ abstract class BaseModel extends Model
break; break;
case 'category_uid': case 'category_uid':
if (is_null($this->_category_options)) { if (is_null($this->_category_options)) {
$this->_category_options = $this->getCategoryModel()->getOptions(['classname' => $this->_className]); $this->_category_options = $this->getCategoryModel()->getOptions();
} }
$options = $this->_category_options; $options = $this->_category_options;
break; break;

View File

@ -11,21 +11,21 @@ class CategoryModel extends BaseHierarchyModel
protected $returnType = CategoryEntity::class; protected $returnType = CategoryEntity::class;
public function __construct() public function __construct()
{ {
parent::__construct('Category'); parent::__construct("Category");
$this->allowedFields = [ $this->allowedFields = [
...$this->allowedFields, ...$this->allowedFields,
'name', "linkurl", "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "name", "linkurl", "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload",
"head", "tail", "status" "head", "tail", "status"
]; ];
$this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),];
} }
public function getTitleField(): string public function getTitleField(): string
{ {
return 'name'; return "name";
} }
public function getContentField(): string public function getContentField(): string
{ {
return 'head'; return "head";
} }
public function getFieldRule(string $field, array $rules, string $action = ""): array public function getFieldRule(string $field, array $rules, string $action = ""): array
{ {
@ -37,7 +37,7 @@ class CategoryModel extends BaseHierarchyModel
$rules[$field] = "required|trim|string"; $rules[$field] = "required|trim|string";
$rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : ""; $rules[$field] .= $action == "insert" ? "|is_unique[{$this->table}.{$field}]" : "";
break; break;
case 'photo': case "photo":
$rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; $rules[$field] = !$action ? "if_exist|string" : "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]";
break; break;
case "isaccess": case "isaccess":
@ -80,9 +80,9 @@ class CategoryModel extends BaseHierarchyModel
foreach ($this->getEntitys($conditions) as $entity) { foreach ($this->getEntitys($conditions) as $entity) {
if ($entity->getHierarchy_Depth() == 1) { if ($entity->getHierarchy_Depth() == 1) {
$old = $entity->getPrimaryKey(); $old = $entity->getPrimaryKey();
$menus[$old] = ['entity' => $entity, 'childs' => []]; $menus[$old] = ["entity" => $entity, "childs" => []];
} else { } else {
$menus[$old]['childs'][] = $entity; $menus[$old]["childs"][] = $entity;
} }
} }
return $menus; return $menus;
@ -99,7 +99,7 @@ class CategoryModel extends BaseHierarchyModel
case "isupload": case "isupload":
case "isdownload": case "isdownload":
if (array_key_exists($field, $formDatas) && $formDatas[$field]) { if (array_key_exists($field, $formDatas) && $formDatas[$field]) {
$entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS['DELIMITER_ROLE'], $formDatas[$field]) : $formDatas[$field]; $entity->$field = is_array($formDatas[$field]) ? implode(DEFAULTS["DELIMITER_ROLE"], $formDatas[$field]) : $formDatas[$field];
} }
break; break;
case "head": case "head":
@ -117,7 +117,7 @@ class CategoryModel extends BaseHierarchyModel
public function getEntity($conditions): CategoryEntity public function getEntity($conditions): CategoryEntity
{ {
return parent::getEntity($conditions); return new CategoryEntity(parent::getEntity($conditions)->toArray());
} }
public function getEntitys(array $conditions = array()): array public function getEntitys(array $conditions = array()): array
{ {