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); }