public function run()
 {
     DB::table('hotels')->delete();
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 5; $i++) {
         $hotel = new Hotel();
         $hotel->hotel_name = $faker->text(20);
         $hotel->pos = $faker->latitude . ',' . $faker->longitude;
         $hotel->tips = $faker->text(20);
         $hotel->save();
         // DB::table('hotels')->insert([
         //    'hotel_name'	=> $faker->text(20),
         //    'pos'	        => $faker->latitude.','.$faker->longitude,
         //    'tips'        => $faker->text(20)
         // ]);
     }
 }
 public function postInsert()
 {
     //load data from ajax request and save to the database
     if (Request::ajax()) {
         $name = Input::get('name');
         $address_line1 = Input::get('address_line1');
         $address_line2 = Input::get('address_line2');
         $city_id = Input::get('city');
         $hotel = new Hotel();
         $hotel->name = $name;
         $hotel->address_line1 = $address_line1;
         $hotel->address_line2 = $address_line2;
         $hotel->city_id = $city_id;
         $hotel->save();
         $response = array('status' => 'success', 'msg' => 'Setting created successfully');
         return 'Hotel is added successfully';
     } else {
         return 'no';
     }
 }
 public function executeSearch()
 {
     $keywords = Input::get('keywords');
     $id = Input::get('city');
     $hotels = Hotel::all();
     $searchhotel = new Collection();
     foreach ($hotels as $hotel) {
         $cityId = $hotel->city_id;
         if (!empty($id)) {
             if (Str::contains(Str::lower($hotel->name), Str::lower($keywords)) && $id == $cityId) {
                 $searchhotel->add($hotel);
             }
         } else {
             if (Str::contains(Str::lower($hotel->name), Str::lower($keywords))) {
                 $searchhotel->add($hotel);
             }
         }
     }
     return View::make('searchedHotels')->with('searchhotel', $searchhotel);
 }
 public function checkOutFromHotel(Request $request)
 {
     $token = $request->input('token');
     $current_iterinary = UserSessionHandler::getUserCurrentIterinary($token);
     $hotel = $current_iterinary->activities()->hotel()->first();
     $hotel = Hotel::find($hotel->typable_id);
     $request = $request->all();
     $hotel->price = $request['price'];
     $hotel->tips = $request['review'];
     $now = Carbon::now();
     $day = $now->diffInDays($hotel->created_at);
     $hotel->days_stayed = $day == 0 ? 1 : $day;
     $hotel->update();
     $hotel->touch();
     UserSessionHandler::updateIterinary($token);
     return response()->json($hotel);
 }
 public function eliminarhotel($id, Request $request)
 {
     Hotel::destroy($id);
     return redirect()->back()->with('alert', 'Hotel Eliminado con Exito');
 }
 /**
  * @param $token
  * @param $hotel_data
  * @param $transpo
  * @return array|\Illuminate\Http\JsonResponse
  */
 public static function addHotel($token, $hotel_data, $transpo)
 {
     $response = UserSessionHandler::resolveNewSegmentFromActivity($token, $transpo, $hotel_data);
     //        return response()->json($response);
     if ($response) {
         return $response;
     }
     $current_iterinary = UserSessionHandler::getUserCurrentIterinary($token);
     $day = UserSessionHandler::getDiffInDays($token, $current_iterinary->id);
     $activity = new Activity();
     $activity->start_time = Carbon::now()->toTimeString();
     $activity->iterinary_id = $current_iterinary->id;
     $activity->day = $day;
     $hotel = new Hotel();
     $hotel->place_name = $hotel_data['place_name'];
     $hotel->lng = $hotel_data['lng'];
     $hotel->lat = $hotel_data['lat'];
     $hotel->tips = $hotel_data['review'];
     $hotel->price = $hotel_data['price'];
     $hotel->foursquare_id = !$hotel_data['foursquare_id'] ? null : $hotel_data['foursquare_id'];
     $hotel->pic_url = '';
     //        return response()->json($eat);
     $hotel->save();
     $hotel->activity()->save($activity);
     $iterinary = Iterinary::findOrFail($current_iterinary->id)->with('activities.typable')->first();
     return response()->json($hotel, 200);
 }
 public function addHotelTest(Request $request)
 {
     $request = $request->all();
     $food_data = $request['hotel'];
     $token = $request['token'];
     $transpo = $request['transpo'];
     $response = UserSessionHandler::resolveNewSegmentFromActivity($token, $transpo, $food_data);
     //        return response()->json($response);
     $current_iterinary = UserSessionHandler::getUserCurrentIterinary($token);
     $day = UserSessionHandler::getDiffInDays($token, $current_iterinary->id);
     $activity = new Activity();
     $activity->start_time = Carbon::now()->toTimeString();
     $activity->iterinary_id = $current_iterinary->id;
     $activity->day = $day;
     $hotel = new Hotel();
     $hotel->hotel_name = $food_data['place_name'];
     $hotel->lng = $food_data['lng'];
     $hotel->lat = $food_data['lat'];
     $hotel->tips = $food_data['review'];
     $hotel->price = $food_data['price'];
     $hotel->pic_url = '';
     //        return response()->json($eat);
     $hotel->save();
     $hotel->activity()->save($activity);
     $iterinary = Iterinary::findOrFail($current_iterinary->id)->with('activities.typable')->first();
     return response()->json($iterinary, 200);
 }
 public function edithabitacion($id)
 {
     $habitacion = Habitacion::where('id', '=', $id)->get()->first();
     $amenidadeshabitacion = Amenidad_Habitacion::where('id_habitacion', $id)->get();
     $amenidades = DB::table('amenidades')->orderBy('nombre')->get();
     $hotel = Hotel::where('id', '=', $habitacion->id_hotel)->get()->first();
     return view('providers.hoteles.habitaciones.edit_habitacion', compact('habitacion', 'amenidades', 'amenidadeshabitacion', 'hotel'));
 }