class ClassTeacher < Base::ClassTeacher
  associations_for legacy: true do |a|
    a.belongs_to :school
    a.belongs_to :classroom, keys: 'ClassID'
    a.belongs_to :employee, keys: :UserID, class_name: '::Employee'
  end

  has_many :news_articles, through: :classroom

  scope :by_teachers, ->(teachers) { where(user_id: teachers) if teachers.present? }
  scope :by_classroom, ->(id) { where(class_id: id) if id.present? }
  scope :by_classroom_type, ->(type) { joins(:classroom).merge(Classroom.by_type(type)) if type }
end
