public static function addOtherActivity($token, $other_data, $transpo) { $response = UserSessionHandler::resolveNewSegmentFromActivity($token, $transpo, $other_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; $other_activity = new OtherActivity(); $other_activity->name = $other_data['place_name']; $other_activity->lng = $other_data['lng']; $other_activity->lat = $other_data['lat']; $other_activity->review = $other_data['review']; $other_activity->expense = $other_data['expense']; // return response()->json($eat); $other_activity->save(); $other_activity->activity()->save($activity); $iterinary = Iterinary::findOrFail($current_iterinary->id)->with('activities.typable')->first(); return response()->json($iterinary, 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); }