Sha256: d5968c412bb4293618ed4907eb4dfb58d9ecaec70dadff10380ba448a052571d

Contents?: true

Size: 651 Bytes

Versions: 1

Compression:

Stored size: 651 Bytes

Contents

class Property < MLS::Model

  include MLS::Slugger
  include MLS::Avatar

  belongs_to :contact, :class_name => 'Account'
  
  has_many :listings
  has_many :localities
  has_many :regions, :through => :localities
  has_many :photos, -> { order('photos.order ASC') }, :as => :subject, :inverse_of => :subject
  # has_many :regions

  has_many   :addresses
  has_one    :address, -> { where(:primary => true) }
  
  def default_contact
    @default_contact ||= listings.where(lease_state: :listed, state: :visible)
            .where({ type: ['Lease', 'Sublease', 'Sale']})
            .order(size: :desc)
            .first.try(:contact)
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mls-1.0.0 lib/mls/property.rb