quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
 
namespace app\operations\model\auth;
 
use app\common\model\plus\operations\UserRole as UserRoleModel;
 
/**
 * 区域代理用户角色模型
 */
class UserRole extends UserRoleModel
{
    /**
     * 获取指定管理员的所有角色id
     * @param $operations_user_id
     * @return array
     */
    public static function getRoleIds($operations_user_id)
    {
        return (new self)->where('operations_user_id', '=', $operations_user_id)->column('role_id');
    }
 
    /**
     * 获取角色下的用户
     */
    public static function getUserRoleCount($role_id){
        $model = new static();
        return $model->alias('userRole')
            ->join('region_user_login', 'userRole.operations_user_id = region_user_login.operations_user_id', 'left')
            ->where('userRole.role_id', '=', $role_id)
            ->where('region_user_login.is_delete', '=', 0)
            ->count();
    }
}