Advertisement
vitareinforce

fungsi detail pesanan backend

Jul 27th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. public function show($id) {
  2. $result = Sales::with('legalEntity', 'branch')->find($id);
  3. $item_details = ItemDetails::select('Id',
  4. 'ItemId',
  5. 'Code',
  6. 'Name',
  7. 'TotalQuantity',
  8. 'Quantity100',
  9. 'Quantity90',
  10. 'Quantity60',
  11. 'Quantity30',
  12. 'BuyingPrice100',
  13. 'BuyingPrice90',
  14. 'BuyingPrice60',
  15. 'BuyingPrice30',
  16. 'Price100',
  17. 'Price90',
  18. 'Price60',
  19. 'Price30',
  20. 'Picture1',
  21. 'BundleId')
  22. ->where('Source', '=', 'Sales')
  23. ->where('SourceId', '=', $id)
  24. ->get();
  25.  
  26. // tarik data bundle parent (untuk keperluan detail barang)
  27. for($id = 0; $id < count($item_details); $id++) {
  28. if($item_details[$id]->BundleId != null) {
  29. $bundle = Bundles::find($item_details[$id]->BundleId);
  30. if($bundle != null) {
  31. $item_details[$id]['bundle'] = array(
  32. 'Id' => $bundle->Id,
  33. 'Name' => $bundle->Name,
  34. 'Code' => $bundle->Code,
  35. 'Picture1' => $bundle->Picture1
  36. );
  37. }
  38. } else {
  39. $item_details[$id]['bundle'] = null;
  40. }
  41. }
  42.  
  43. $result['item_details'] = $item_details;
  44. return response()->json($result);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement