diff --git a/app/Cells/ProductCell.php b/app/Cells/ProductCell.php index 01340e5..7180962 100644 --- a/app/Cells/ProductCell.php +++ b/app/Cells/ProductCell.php @@ -27,7 +27,7 @@ class ProductCell extends BaseCell foreach ($this->getProductDeviceModel()->getEntitys( ['product_uid' => $cellDatas['entity']->getPrimaryKey()] ) as $productDevieceEntity) { - $cellDatas['defaults'][$productDevieceEntity->device_uid] = $productDevieceEntity; + $cellDatas['defaults'][] = $productDevieceEntity->device_uid; } } $cellDatas['device'] = []; diff --git a/app/Controllers/Admin/ProductController.php b/app/Controllers/Admin/ProductController.php index 329f1dd..0e64696 100644 --- a/app/Controllers/Admin/ProductController.php +++ b/app/Controllers/Admin/ProductController.php @@ -92,7 +92,7 @@ class ProductController extends AdminController } //가상서버 - protected function virtual_process(ProductEntity $entity): array + protected function virtual_process(ProductEntity $entity) { //가상서버정보 $protudctDatas = array( @@ -129,11 +129,10 @@ class ProductController extends AdminController $protudctDatas['name'] = implode(" ", $titles); $protudctDatas['content'] = implode("\n", $titles); $product = $this->getModel()->create($protudctDatas); - return array(); //return $this->add_procedure($product, 1, $this->_viewDatas['fieldDatas']['paymentday']); } //주문처리 - protected function device_process(ProductEntity $entity): array + protected function device_process(ProductEntity $entity) { switch ($this->_viewDatas['fieldDatas']['category']) { case 'virtual': @@ -141,23 +140,23 @@ class ProductController extends AdminController break; case 'beremetal': //상품관련 tw_product_device 기존정보 삭제처리 - foreach ($this->getProductDeviceModel()->getEntitys( - ['product_uid' => $entity->getPrimaryKey()] - ) as $productDeviceEntity) { - $this->getProductDeviceModel()->delete($productDeviceEntity); + $productDeviceEntitys = $this->getProductDeviceModel()->getEntitys(['product_uid' => $entity->getPrimaryKey()]); + foreach ($productDeviceEntitys as $productDeviceEntity) { + $this->getProductDeviceModel()->delete($productDeviceEntity->getPrimaryKey()); } //상품관련 tw_product_device 기존정보 생성처리 - $devices = []; foreach (['server', 'cpu', 'memory', 'disk', 'nic', 'publicip', 'os'] as $field) { - $formDatas = ['product_uid' => $entity->getPrimaryKey()]; - $formDatas['device_uid'] = $this->request->getPost($field); - $formDatas['device_cnt'] = $this->request->getPost($field . "_cnt") ?: 1; - if ($formDatas['product_uid'] && $formDatas['device_uid']) { - $devices[$field] = $this->getProductDeviceModel()->create($formDatas); + $device_uids = $this->request->getPost($field) ?: []; + // dd($device_uids); + 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); + } } } - // dd($devices); - return $devices; break; default: throw new \Exception($this->_viewDatas['fieldDatas']['category'] . "는 알수없는 상품 구분입니다. 다시 확인 부탁드립니다."); @@ -170,7 +169,7 @@ class ProductController extends AdminController { $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); $entity = parent::insert_process(); - $entity->setDevices($this->device_process($entity)); + $this->device_process($entity); return $entity; } //Update관련 @@ -178,7 +177,7 @@ class ProductController extends AdminController { $this->_viewDatas['fieldDatas']['price'] = $this->calculate_price(); $entity = parent::update_process($entity); - $entity->setDevices($this->device_process($entity)); + $this->device_process($entity); // dd($entity); return $entity; } diff --git a/app/Entities/ProductEntity.php b/app/Entities/ProductEntity.php index 8da6c0f..0bf5326 100644 --- a/app/Entities/ProductEntity.php +++ b/app/Entities/ProductEntity.php @@ -42,12 +42,4 @@ class ProductEntity extends BaseEntity } return $price; } - public function getDevices(): array - { - return $this->_devices; - } - public function setDevices(array $devices) - { - $this->_devices = $devices; - } } diff --git a/app/Views/cells/product/device.php b/app/Views/cells/product/device.php index d9d939b..0b84121 100644 --- a/app/Views/cells/product/device.php +++ b/app/Views/cells/product/device.php @@ -8,7 +8,7 @@