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\common\model\plus\operations;
 
use app\common\model\BaseModel;
 
/**
 * 运营中心用户角色关系模型
 */
class UserRole extends BaseModel
{
    protected $name = 'operations_user_role';
    protected $pk = 'id';
 
    /**
     * 关联角色
     * @return \think\model\relation\BelongsTo
     */
    public function role()
    {
        return $this->belongsTo('Role', 'role_id', 'role_id');
    }
 
    /**
     * 获取用户的角色ID列表
     * @param int $userId 用户ID
     * @return array
     */
    public static function getUserRoleIds($userId)
    {
        return self::where('operations_user_id', '=', $userId)->column('role_id');
    }
}