21 lines
528 B
Ruby
21 lines
528 B
Ruby
class DiningFacility < ApplicationRecord
|
|
belongs_to :zone
|
|
|
|
TABLE_TYPE = "Table"
|
|
ROOM_TYPE = "Room"
|
|
|
|
default_scope { order('order_by asc') }
|
|
|
|
scope :active, -> {where(is_active: true)}
|
|
|
|
def get_current_booking
|
|
booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='occupied' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1)
|
|
|
|
if booking.count > 0 then
|
|
return booking[0]
|
|
else
|
|
return nil
|
|
end
|
|
end
|
|
end
|