Breezebnb is a accommodation booking website inspired by Airbnb!
Breezebnb enables travelers to book unique accommodations and cool places all over the world, from apartments and houses to villas, directly from the property owners or hosts. Users can search for properties by specific categories. Plus, users can share their thoughts about their stay by leaving reviews and ratings.
def overlap
Reservation.where('reserved_room_id = ? AND ((checkin < ? AND checkout > ?)
OR (checkin < ? AND checkout > ?) OR (checkin >= ? AND checkout <= ?))',
reserved_room_id, checkout, checkout, checkin, checkin, checkin, checkout)
end
def create
@reservation = Reservation.new(reservation_params)
room = Room.find_by(id: params[:reservation][:reserved_room_id])
if room
@reservation.room = room
if @reservation.overlap.exists?
render json: {error: 'Room is already booked for the requested dates'}, status: 422
elsif @reservation.save
render :show
else
render json: {errors: @reservation.errors}, status: 422
end
else
render json: {error: "Room not found" }, status: 404
end
end
Front End
Back end
Database
Cloud