class SalesmanCustomer < ApplicationRecord
  belongs_to :salesman, :touch => true, counter_cache: true
  belongs_to :school
  belongs_to :user

  def name
    user.real_name
  end

  def school_name
    school.name
  end

  def courses_count
    CourseMember.where(user_id: id).teachers_and_admin.count
  end

  def shixuns_count
    ShixunMember.where(user_id: id, role: [1, 2]).count
  end

end