|
|
|
@ -13,6 +13,8 @@ class Subject < ApplicationRecord
|
|
|
|
|
has_many :stage_shixuns, dependent: :destroy
|
|
|
|
|
has_many :shixuns, through: :stage_shixuns
|
|
|
|
|
|
|
|
|
|
has_many :subject_appointments, dependent: :destroy
|
|
|
|
|
|
|
|
|
|
has_many :subject_members, ->{ order("subject_members.position asc")}, dependent: :destroy
|
|
|
|
|
has_many :users, through: :subject_members
|
|
|
|
|
has_many :tidings, as: :container, dependent: :destroy
|
|
|
|
@ -109,4 +111,10 @@ class Subject < ApplicationRecord
|
|
|
|
|
def learning? user_id
|
|
|
|
|
Myshixun.where(user_id: user_id, shixun_id: shixuns).exists?
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def start_course_notify
|
|
|
|
|
Tiding.create(user_id: user_id, trigger_user_id: 0, container_id: id,
|
|
|
|
|
container_type: 'SubjectStartCourse', belong_container_id: id,
|
|
|
|
|
belong_container_type: 'Subject', tiding_type: 'System')
|
|
|
|
|
end
|
|
|
|
|
end
|