Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function show($id) {
- $result = Sales::with('legalEntity', 'branch')->find($id);
- $item_details = ItemDetails::select('Id',
- 'ItemId',
- 'Code',
- 'Name',
- 'TotalQuantity',
- 'Quantity100',
- 'Quantity90',
- 'Quantity60',
- 'Quantity30',
- 'BuyingPrice100',
- 'BuyingPrice90',
- 'BuyingPrice60',
- 'BuyingPrice30',
- 'Price100',
- 'Price90',
- 'Price60',
- 'Price30',
- 'Picture1',
- 'BundleId')
- ->where('Source', '=', 'Sales')
- ->where('SourceId', '=', $id)
- ->get();
- // tarik data bundle parent (untuk keperluan detail barang)
- for($id = 0; $id < count($item_details); $id++) {
- if($item_details[$id]->BundleId != null) {
- $bundle = Bundles::find($item_details[$id]->BundleId);
- if($bundle != null) {
- $item_details[$id]['bundle'] = array(
- 'Id' => $bundle->Id,
- 'Name' => $bundle->Name,
- 'Code' => $bundle->Code,
- 'Picture1' => $bundle->Picture1
- );
- }
- } else {
- $item_details[$id]['bundle'] = null;
- }
- }
- $result['item_details'] = $item_details;
- return response()->json($result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement