_deviceModel = $this->_deviceModel ?: new DeviceModel(); } final protected function getProductDeviceModel(): ProductDeviceModel { return $this->_productDeviceModel = $this->_productDeviceModel ?: new ProductDeviceModel(); } public function device(array $cellDatas = []) { $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['selecteds'][$cellDatas['deviceEntitys'][$productDevieceEntity->device_uid]->getCategory()][$productDevieceEntity->getPrimaryKey()] = $productDevieceEntity; } } $cellDatas['device'] = []; $cellDatas['device']['options'] = $this->getDeviceModel()->getOptions(); //dd($cellDatas); return view( 'Views/cells/product/' . __FUNCTION__, ['cellDatas' => $cellDatas] ); } public function device_calulator(array $cellDatas = []): string { $cellDatas['categorys'] = DEVICE['CATEGORYS']; $cellDatas['device'] = []; $cellDatas['device']['options'] = $this->getDeviceModel()->getOptions(); return view( 'Views/cells/product/' . __FUNCTION__, ['cellDatas' => $cellDatas] ); } }