add: setting of system notification

This commit is contained in:
2021-10-12 16:34:00 +08:00
parent d176508010
commit 490ce7a234
4 changed files with 29 additions and 7 deletions

View File

@@ -12,6 +12,15 @@
class SystemNotification < ApplicationRecord
default_scope { order(created_at: :desc)}
has_many :system_notification_histories
has_many :users, through: :system_notification_histories
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
end