You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/salesman_customer.rb

23 lines
414 B

class SalesmanCustomer < ApplicationRecord
belongs_to :salesman, :touch => true, counter_cache: true
belongs_to :school, optional: true
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