예제 #1
0
 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;
 }
 /**
  * Remove the specified rate from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($hotelid, $id)
 {
     SupplementRate::destroy($id);
     return Redirect::back();
 }