get(['id', 'name'])->toArray(); // var_dump($this->testFileMod); return view('admin.priceListProfitCenter.index')->with( ['suppliers' => $suppliers, // 'testFileMod'=>($this->testFileMod)?'true':'false' ] ); } public function getDataTableContent(): JsonResponse { $groupId = null; $searchStr = null; if (\request()->get('supplierId')) { $supplierId = \request()->get('supplierId'); } else { return \response()->json(['data' => []]); } if (\request()->get('deliveryDate')) { $deliveryDate = \request()->get('deliveryDate'); } else { $deliveryDate = Carbon::now()->format('Y-m-d'); } $special = []; $special['withFavorites'] = true; if (\request()->get('searchStr')) { $searchStr = \request()->get('searchStr'); if (substr($searchStr, 0, 2) == '**') { $special['type'] = str_replace('*', '', $searchStr); $searchStr = null; } } else { if (\request()->get('groupId')) { $groupId = \request()->get('groupId'); } } if (\request()->get('krel')) { if (request()->get('krel') === 'true') { $special['krel'] = 1; } } debug(\request()->all()); $productRepo = new ProductRepository; $productRepo->setRelation( 'ProductGroup', 'Supplier', 'Producer', 'PriceList', 'LastPrice'); // $products=$productRepo->getByGroupId($groupId,true); $products = $productRepo->getSupplierProductFromPriceList($supplierId, null, $deliveryDate, $groupId, $searchStr, $special); // debug($products[1]); $ret = ['data' => []]; // dd($products[0]); foreach ($products as $product) { // dd(count($product['price_list'])); // if(count($product['price_list'])>0){ if ($product['price_list_price']) { $data = []; $data['id'] = $product['id']; $data['name'] = $product['name']; $data['packing'] = $product['packing']; $data['unitValue'] = $product['unitValue']; $data['productUnit'] = $product['productUnit']; $data['sellerUnit'] = $product['sellerUnit']; $data['unitMultiplier'] = $product['unitMultiplier']; $data['amountUnit'] = $product['amountUnit']; $data['note'] = ($product['note'] ? $product['note'] : ''); // $product['product_group']['name']; // $data['price']=$product['last_price'][0]['pivot']['price']; $data['price'] = $product['price_list_price']['price']; $data['hooreycaId'] = $product['hooreycaId']; $data['office'] = ''; $data['extn'] = ''; $data['favorites'] =0; if(isset($product['favorites'])){ $data['favorites'] = $product['favorites']; } $data['stock_status'] = $product['stock_status'] ?? 'in_stock'; if ($product['krel'] == 1) { $product['krel'] = '*'; } else { $product['krel'] = ''; } $data['krel'] = $product['krel']; $ret['data'][] = $data; } else { } } return \response()->json($ret); return \response()->file('exapmle2.json'); } public function getProductGroupHTML(): View { $productRepo = new ProductRepository; $productsGroupIds = $productRepo->getSupplierProductGroupsIdFromPriceList( \request()->get('supplierId'), \request()->get('deliveryDate')); $productGroupArray = []; if ($productsGroupIds && count($productsGroupIds) > 0) { $ProductGroups = new ProductGroup; $productGroupArray = $ProductGroups->nodesWithParentToTree($productsGroupIds); } return view('modules.order.productSelectSidebarProductGroupPartial')->with(['productGroup' => $productGroupArray]); dd($productGroupArray); } }