Пример #1
0
 /**
  * Display a listing of hotels
  *
  * @return Response
  */
 public function getIndex()
 {
     if (Input::has('pais')) {
         $string = Input::get('pais');
         $pais = Pais::Where('name', 'LIKE', "%{$string}%")->first();
         if ($pais) {
             $hoteis = Hotel::Where('pais_id', '=', $pais->id)->with('caracteristicas')->paginate(5);
             if (count($hoteis) > 0) {
                 $hotels = $hoteis;
                 $count = $hoteis->count();
             }
         } else {
             $hotels = array();
             $count = 0;
         }
     } else {
         $hotels = Hotel::with('pais', 'caracteristicas')->Where('publicado', '=', 1)->paginate(5);
         $count = Hotel::with('pais')->Where('publicado', '=', 1)->count();
     }
     $paises = Pais::has('hoteis')->get();
     foreach ($paises as $pais) {
         $json[] = $pais->name;
     }
     $json = json_encode($json);
     return View::make('hotels.index', compact('hotels', 'count', 'json'));
 }
Пример #2
0
 public function hotelDetail()
 {
     if (Input::has('hotel_id')) {
         $hotel_id = Input::get('hotel_id');
         Session::put('hotel_id', $hotel_id);
     } else {
         $hotel_id = Session::get('hotel_id');
     }
     if (Session::has('market')) {
         $market = Session::get('market');
     }
     $st_date = Session::get('st_date');
     $ed_date = Session::get('ed_date');
     $date_ed = new DateTime(Session::get('ed_date'));
     $date_st = new DateTime(Session::get('st_date'));
     $date_difference = $date_ed->diff($date_st);
     $date_gap = $date_difference->d;
     Session::put('date_gap', $date_gap);
     if (Input::has('room_type')) {
         $room_type = Input::get('room_type');
         Session::put('filter_room_type', $room_type);
         $meal_basis = Session::get('filter_meal_type');
     } else {
         $room_type = Session::get('room_type');
     }
     if (Input::has('meal_type')) {
         $meal_basis = Input::get('meal_type');
         Session::put('filter_meal_type', $meal_basis);
         $room_type = Session::get('filter_room_type');
     } else {
         $meal_basis = Session::get('meal_basis');
     }
     //dd($meal_basis.'/'.$room_type);
     $from_date = date('Y-m-d', strtotime(str_replace('-', '/', $st_date)));
     $to_date = date('Y-m-d', strtotime(str_replace('-', '/', $ed_date)));
     $path = array();
     $directory = public_path() . '/images/hotel_images/';
     $images = glob($directory . $hotel_id . "_" . "*.*");
     foreach ($images as $image) {
         $path[] = $image;
     }
     //dd($hotel_id);
     $hotel_name = Hotel::Where('id', $hotel_id)->first()->name;
     $get_rooms = DB::table('rates')->select('rates.id as rate_id', 'rates.from', 'rates.to', 'rates.rate', 'hotels.id as hotel_id', 'hotels.name as hotel_name', 'hotels.star_category_id', 'hotels..city_id', 'meal_bases.id as meal_basis_id', 'meal_bases.meal_basis', 'meal_bases.meal_basis_name', 'room_types.id as room_type_id', 'room_types.room_type', 'room_specifications.id as room_specification_id', 'room_specifications.room_specification')->join('hotels', 'hotels.id', '=', 'rates.hotel_id')->join('meal_bases', 'meal_bases.id', '=', 'rates.meal_basis_id')->join('room_types', 'room_types.id', '=', 'rates.room_type_id')->join('room_specifications', 'room_specifications.id', '=', 'rates.room_specification_id')->where('rates.val', 1)->where('rates.hotel_id', $hotel_id)->where('rates.room_specification_id', 'LIKE', $room_type)->where('rates.meal_basis_id', 'LIKE', $meal_basis)->where('rates.from', '<=', $from_date)->where('rates.to', '>', $from_date)->get();
     //     dd(count($get_rooms));
     if (!empty($get_rooms)) {
         foreach ($get_rooms as $room) {
             $hotel_id = $room->hotel_id;
             $room_type_id = $room->room_type_id;
             $room_specification_id = $room->room_specification_id;
             $meal_basis_id = $room->meal_basis_id;
             $room_type = $room->room_type;
             $meal_basis = $room->meal_basis;
             $room_specification = $room->room_specification;
             //dd($room_type_id.'/'.$room_specification_id.'/'.$meal_basis_id);
             $get_low_hotel_rate = Rate::lowestRoomRateWithTax($hotel_id, $room_type_id, $room_specification_id, $meal_basis_id, $st_date, $ed_date);
             if ($get_low_hotel_rate > 0) {
                 $low_room_rate = $get_low_hotel_rate;
             } else {
                 $low_room_rate = 0;
             }
             $allotments = Allotment::allotmentsCount($room_type_id, Session::get('st_date'), Session::get('ed_date'));
             $room_array = array('hotel_id' => $hotel_id, 'room_type_id' => $room_type_id, 'room_specification_id' => $room_specification_id, 'meal_basis_id' => $meal_basis_id, 'room_type' => $room_type, 'meal_basis' => $meal_basis, 'room_specification' => $room_specification, 'low_room_rate' => $low_room_rate, 'allotments' => $allotments);
             $rooms[] = $room_array;
             //array_push($rooms, $room_array);
             array_merge($rooms, $room_array);
             // dd(count($get_rooms));
         }
     } else {
         return null;
     }
     return Response::json(array('hotel_name' => $hotel_name, 'rooms' => $rooms));
     //
 }