<?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');
|
}
|
}
|