Sha256: 5ad434345f84fef293ee27a0504ff69e4d031df4c7609cba04bb9534661d1edb

Contents?: true

Size: 646 Bytes

Versions: 6

Compression:

Stored size: 646 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

6 entries across 6 versions & 1 rubygems

Version Path
mls-1.2.0 lib/mls/property.rb
mls-1.1.4 lib/mls/property.rb
mls-1.1.3 lib/mls/property.rb
mls-1.1.2 lib/mls/property.rb
mls-1.1.1 lib/mls/property.rb
mls-1.1.0 lib/mls/property.rb