diff --git a/app/Cells/ProductCell.php b/app/Cells/ProductCell.php index 7180962..1092f26 100644 --- a/app/Cells/ProductCell.php +++ b/app/Cells/ProductCell.php @@ -22,16 +22,23 @@ class ProductCell extends BaseCell public function device(array $cellDatas = []) { - $cellDatas['defaults'] = []; + $cellDatas['deviceEntitys'] = []; + foreach ($this->getDeviceModel()->getEntitys() as $deviceEntity) { + $cellDatas['deviceEntitys'][$deviceEntity->getPrimaryKey()] = $deviceEntity; + } + $cellDatas['categorys'] = DEVICE['CATEGORYS']; + $cellDatas['selecteds'] = []; + foreach ($cellDatas['categorys'] as $category) { + $cellDatas['selecteds'][$category] = []; + } if (array_key_exists('entity', $cellDatas)) { foreach ($this->getProductDeviceModel()->getEntitys( ['product_uid' => $cellDatas['entity']->getPrimaryKey()] ) as $productDevieceEntity) { - $cellDatas['defaults'][] = $productDevieceEntity->device_uid; + $cellDatas['selecteds'][$cellDatas['deviceEntitys'][$productDevieceEntity->device_uid]->getCategory()][$productDevieceEntity->getPrimaryKey()] = $productDevieceEntity; } } $cellDatas['device'] = []; - $cellDatas['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os']; $cellDatas['device']['options'] = $this->getDeviceModel()->getOptions(); //dd($cellDatas); return view( @@ -42,10 +49,9 @@ class ProductCell extends BaseCell public function device_calulator(array $cellDatas = []): string { + $cellDatas['categorys'] = DEVICE['CATEGORYS']; $cellDatas['device'] = []; - $cellDatas['device']['categorys'] = ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os']; $cellDatas['device']['options'] = $this->getDeviceModel()->getOptions(); - return view( 'Views/cells/product/' . __FUNCTION__, ['cellDatas' => $cellDatas] diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 8ead8b7..cb60d86 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -171,8 +171,6 @@ define('SESSION_NAMES', [ 'CART' => 'cart' ]); define('AUTH_FIELDS', ['ID' => 'id', 'TITLE' => 'title', 'ROLE' => 'role']); -//월이용권 상품의 Category번호 -define('RENTAL_PRODUCT_CATEGORYS', [5, 8]); //인증 관련 define('AUTH_ADAPTERS', [ 'Local' => [ @@ -314,3 +312,8 @@ define('API', [ 'COOKIE_FILE' => PATHS['API'] . getenv('api.cookie.file') ?: "api-cookie_" . date("Ymd") . ".log", 'DEBUG_FILE' => PATHS['API'] . getenv('api.debug.file') ?: "api-debug_" . date("Ymd") . ".log", ]); + +//Device Categorys +define('DEVICE', [ + 'CATEGORYS' => getenv('device.categorys') ?: ['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'], +]); diff --git a/app/Controllers/Admin/ProductController.php b/app/Controllers/Admin/ProductController.php index 0e64696..8132892 100644 --- a/app/Controllers/Admin/ProductController.php +++ b/app/Controllers/Admin/ProductController.php @@ -144,18 +144,16 @@ class ProductController extends AdminController foreach ($productDeviceEntitys as $productDeviceEntity) { $this->getProductDeviceModel()->delete($productDeviceEntity->getPrimaryKey()); } - //상품관련 tw_product_device 기존정보 생성처리 - foreach (['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'] as $field) { + //상품관련 tw_product_device 생성처리 + foreach (DEVICE['CATEGORYS'] as $field) { $device_uids = $this->request->getPost($field) ?: []; - // dd($device_uids); + $productDeviceEntitys = []; foreach ($device_uids as $device_uid) { $formDatas = ['product_uid' => $entity->getPrimaryKey()]; $formDatas['device_uid'] = $device_uid; - $formDatas['device_cnt'] = $this->request->getPost($field . "_cnt") ?: 1; - if ($formDatas['product_uid'] && $formDatas['device_uid']) { - $this->getProductDeviceModel()->create($formDatas); - } + $productDeviceEntitys[] = $this->getProductDeviceModel()->create($formDatas); } + //dd($productDeviceEntitys); } break; default: diff --git a/app/Database/base.sql b/app/Database/base.sql index 2803d2b..124719e 100644 --- a/app/Database/base.sql +++ b/app/Database/base.sql @@ -153,7 +153,6 @@ CREATE TABLE vhost.tw_product_device ( uid int(10) unsigned NOT NULL AUTO_INCREMENT, product_uid varchar(36) NOT NULL COMMENT '상품 정보', device_uid varchar(36) NOT NULL COMMENT '장비 정보', - device_cnt int(3) unsigned NOT NULL DEFAULT 1 COMMENT '장비 갯수', updated_at timestamp NULL DEFAULT NULL, created_at timestamp NOT NULL DEFAULT current_timestamp(), deleted_at timestamp NULL DEFAULT NULL, diff --git a/app/Models/BaseHierarchyModel.php b/app/Models/BaseHierarchyModel.php index 477e69c..16a2b46 100644 --- a/app/Models/BaseHierarchyModel.php +++ b/app/Models/BaseHierarchyModel.php @@ -16,11 +16,11 @@ abstract class BaseHierarchyModel extends BaseModel abstract public function getContentField(); abstract public function reply($parent_entity, array $formDatas): BaseEntity; - public function getEntitys(array $conditions = [], array $entitys = []): array + public function getEntitys(array $conditions = []): array { $this->orderBy("grpno DESC"); $this->orderBY("grporder ASC"); - return parent::getEntitys($conditions, $entitys); + return parent::getEntitys($conditions); } public function getSiblingEntitys($entity) { diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index e8cb10c..23ebbb5 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -266,10 +266,10 @@ abstract class BaseModel extends Model } $entity = $this->save_process($entity); //primaryKey가 자동입력이면 - if ($this->useAutoIncrement) { - $pk = $this->primaryKey; - $entity->$pk = $this->insertID(); - } + // if ($this->useAutoIncrement) { + // $pk = $this->primaryKey; + // $entity->$pk = $this->insertID(); + // } return $entity; } final protected function modify_process($entity, array $formDatas) diff --git a/app/Models/DeviceModel.php b/app/Models/DeviceModel.php index 678545d..6413e56 100644 --- a/app/Models/DeviceModel.php +++ b/app/Models/DeviceModel.php @@ -69,11 +69,11 @@ class DeviceModel extends BaseModel return $options; } - public function getEntitys(array $conditions = array(), $entitys = array()): array + public function getEntitys(array $conditions = array()): array { $this->orderBy("category ASC"); $this->orderBY("price DESC"); - return parent::getEntitys($conditions, $entitys); + return parent::getEntitys($conditions); } public function create(array $formDatas): DeviceEntity { diff --git a/app/Models/ProductDeviceModel.php b/app/Models/ProductDeviceModel.php index 3c51778..8676e2c 100644 --- a/app/Models/ProductDeviceModel.php +++ b/app/Models/ProductDeviceModel.php @@ -12,7 +12,7 @@ class ProductDeviceModel extends BaseModel { parent::__construct('ProductDevice'); $this->allowedFields = [ - ...$this->allowedFields, "product_uid", "device_uid", "device_cnt" + ...$this->allowedFields, "product_uid", "device_uid", ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } @@ -27,9 +27,6 @@ class ProductDeviceModel extends BaseModel case "device_uid": $rules[$field] = $this->getUUIDFieldRule('required'); break; - case 'device_cnt': - $rules[$field] = "required|numeric"; - break; default: $rules = parent::getFieldRule($field, $rules, $action); break; diff --git a/app/Views/cells/product/device.php b/app/Views/cells/product/device.php index 0b84121..efc501c 100644 --- a/app/Views/cells/product/device.php +++ b/app/Views/cells/product/device.php @@ -1,22 +1,42 @@ + - + - + + + + + +
+ $productDevieceEntity) : ?> +
device_uid]->getTitle() ?>
+ +
- $category, - 'size' => "6", - 'class' => 'vhost_cellDatas' - ] - ) ?> + $label) : ?> + +