<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class ServiceRole extends BaseModel
{
    use HasFactory;

    const MAIN_COACH = 1; // 主教练
    const COACH = 2; // 副教练
    const CUSTOMER = 3; // 客服
    const PARTNER = 4; // 合作伙伴
    const CHANNEL = 5; // 渠道商
    const CHEF = 6; // 餐饮人员
    const COUNCIL = 7; // 委员会
    const ADMINISTRATIVE = 8; // 行政
    const REFERRER = 9; // 推荐人
    const ASSISTANT = 10; // 助攻人
    const TUTOR = 11; // 助教
    const STANDARD_AGENT = 12; // 标准代理商
    const SENIOR_AGENT = 13; // 高级代理商
    const CHNNEL = 14; // 渠道商
    const PERSONAL_COACH = 15; // 专属客服
    const INTERN_COACH = 16; // 实习副教练

    public function roleUsers()
    {
        return $this->hasManyThrough(ServiceUser::class, ServiceRoleOrder::class, 'role_id', 'user_id', 'id', 'user_id');
    }

    public function service_user()
    {
        return $this->belongsToMany(ServiceUser::class, 'service_role_users', 'role_id', 's_user_id')->withTimestamps();
    }


    public function roleOrders()
    {
        return $this->hasMany(Order::class, 'role_id', 'id');
    }
}
