forgeplus/app/models/system_notification.rb

28 lines
681 B
Ruby
Raw Permalink Normal View History

2021-10-12 16:14:45 +08:00
# == Schema Information
#
# Table name: system_notifications
#
# id :integer not null, primary key
# subject :string(255)
# sub_subject :string(255)
2021-10-13 17:13:57 +08:00
# content :text(65535)
# is_top :boolean
2021-10-12 16:14:45 +08:00
# created_at :datetime not null
# updated_at :datetime not null
#
class SystemNotification < ApplicationRecord
2021-10-12 16:34:00 +08:00
default_scope { order(created_at: :desc)}
has_many :system_notification_histories
has_many :users, through: :system_notification_histories
2021-10-12 16:34:00 +08:00
scope :is_top, lambda { where(is_top: true) }
def read_member?(user_id)
self.system_notification_histories.where(user_id: user_id).present? ? true : false
end
2021-10-12 16:14:45 +08:00
end