public function showInvoice($bookCode) { $about = About::all(); $booking = DetailBooking::join('booking', 'booking.ID_Booking', '=', 'detail_booking.ID_Booking')->join('roomtype', 'roomtype.ID_RoomType', '=', 'detail_booking.ID_RoomType')->join('guest', 'guest.ID_Booking', '=', 'detail_booking.ID_Booking')->join('payment', 'payment.ID_Booking', '=', 'detail_booking.ID_Booking')->join('extra', 'extra.ID_Booking', '=', 'detail_booking.ID_Booking')->where('booking.Booking_code', '=', $bookCode)->get(); $guest = Guest::join('booking', 'booking.ID_Booking', '=', 'guest.ID_Booking')->where('booking.Booking_code', '=', $bookCode)->get(); $tax = Tax::where('Status', '=', 'Active')->get(); $detailAdd = DetailBooking::join('booking', 'booking.ID_Booking', '=', 'detail_booking.ID_Booking')->join('detail_additional', 'detail_additional.ID_Booking', '=', 'detail_booking.ID_Booking')->join('additional', 'additional.ID_Additional', '=', 'detail_additional.ID_Additional')->where('booking.Booking_code', '=', $bookCode)->get(); $totalRoom = 0; foreach ($booking as $key => $value1) { $totalRoom += $value1->Price * $value1->Quantity * $value1->Number_nights; } //dd($totalRoom); $totalAdd = 0; foreach ($detailAdd as $key => $value) { $totalAdd += $value->Price * $value->Quantity; } //dd($totalAdd); $totalTax = 0; foreach ($tax as $key => $value2) { $totalTax += ($totalAdd + $totalRoom) * $value2->Tax; } //dd($totalTax); $grandTotal = $totalAdd + $totalRoom + $totalTax; //dd($grandTotal); return View::make('Books.View.show')->with('booking', $booking)->with('about', $about)->with('guest', $guest)->with('tax', $tax)->with('detailAdd', $detailAdd)->with('totalRoom', $totalRoom)->with('totalAdditional', $totalAdd)->with('totalTax', $totalTax)->with('grandTotal', $grandTotal); }