public static function supplementRate($hotel_id, $room_type_id, $specification_id, $meal_basis_id, $st_date, $ed_date) { $x = 0; $y = 0; $supplement_rates = 0; if (Session::has('market')) { $market = Session::get('market'); } else { $market = 1; } $get_market_details = Market::where('id', $market)->first(); $from_date = date('Y-m-d', strtotime(str_replace('-', '/', $st_date))); $to_date = date('Y-m-d', strtotime(str_replace('-', '/', $ed_date))); $dates = (strtotime($ed_date) - strtotime($st_date)) / 86400; // dd($market.'/'.$hotel_id.'/'.$room_type_id.'/'.$specification_id.'/'.$meal_basis_id.'/'.$st_date.'/'.$ed_date); for ($x = 1; $x <= $dates; $x++) { $supplement_rate = 0; $get_supplement_rates = SupplementRate::where('hotel_id', $hotel_id)->where('room_type_id', $room_type_id)->where('room_specification_id', $specification_id)->where('meal_basis_id', $meal_basis_id)->where('from', '<=', $from_date)->where('to', '>', $from_date)->where('market_id', $market)->get(); foreach ($get_supplement_rates as $get_supplement_rate) { $supplement_rate = $get_supplement_rate->rate; if ($supplement_rate > 0) { $y = $y + 1; } } $from_date = date('Y-m-d', strtotime($from_date . ' + 1 days')); if ($supplement_rate > 0) { $supplement_rates = $supplement_rates + $supplement_rate; } } $room_supplement_rate = number_format($supplement_rates, 2); return $room_supplement_rate; }
/** * Show the form for editing the specified rate. * * @param int $id * @return Response */ public function edit($hotelid, $id) { $rate = SupplementRate::find($id); $rates = SupplementRate::where('from', $rate->from)->where('to', $rate->to)->where('room_type_id', $rate->room_type_id)->where('market_id', $rate->market_id)->get(); $checkedmarketids = array(); $roomtype = RoomType::with('roomSpecification')->find($rate->room_type_id); $mealbases = MealBasis::all(); return View::make('control-panel.hotel.supplement-rates.edit', compact('hotelid', 'rate', 'rates', 'mealbases', 'checkedmarketids', 'roomtype')); }