/**
  * @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 checkIn(Request $request)
 {
     $hotel_data = $request->input('hotel');
     $transpo_data = $request->input('transpo');
     $token = $request->input('token');
     //        $inputs = $request->all();
     //        return response()->json($inputs);
     $current_iterinary = UserSessionHandler::getUserCurrentIterinary($token);
     $response = UserSessionHandler::resolveNewSegmentFromActivity($token, $transpo_data, $hotel_data);
     $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'];
     if (isset($hotel['foursquare_id'])) {
         $hotel->foursquare_id = $hotel_data['foursquare_id'];
     }
     $hotel->save();
     $hotel->activity()->save($activity);
     return response()->json($hotel);
 }
 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);
 }