Files
sx-fc/app/models/dining_facility.rb
2017-04-15 12:52:40 +06:30

18 lines
483 B
Ruby

class DiningFacility < ApplicationRecord
belongs_to :zone
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