class PamRole extends Model implements RbacRoleContract mixin Eloquent

用户角色

Traits

角色 Trait

Constants

BE_ROOT

FE_USER

Properties

$timestamps
protected $table
protected $fillable
int $id ID
string $name 标识
string $title 角色名称
string $description 描述
string $type 角色组
bool $is_system 是否系统
int $is_enable 是否可用
Collection|PamPermission[] read-only $perms
Collection|PamAccount[] read-only $users

Methods

Collection|mixed
cachedPermissions()

No description

static void
boot()

No description

flushPermissionRole()

清理权限

BelongsToMany
users()

No description

BelongsToMany
perms()

Many-to-Many relations with the permission model.

void
savePermissions($permissions)

No description

void
syncPermission($id)

No description

void
attachPermission(object|array|Permission $id)

给角色添加权限, 并且清空角色缓存

void
detachPermission(object|array $id)

Detach permission from current role.

void
attachPermissions(array $permissions)

No description

void
detachPermissions(array $permissions)

No description

bool
hasPermission(string|array $name, bool $require_all = false)

Checks if the role has a permission by its name.

static void
clearCachedPermissions()

No description

static void
clearCachedPivotPermissions($role_id)

No description

static mixed
getAccountTypeByRoleId(int $role_id)

通过角色来获取账户类型, 由于角色在单条处理中不会存在变化, 故而可以进行静态缓存

static Collection
getLinear(null|string $type = null, string $key = 'id')

返回一维的角色对应

static array
getAll(string|null $accountType = null, bool $cache = true)

根据账户类型获取角色

static null
info(int $id, null $key = null, bool $cache = true)

获取角色信息

Details

in RbacRoleTrait at line 23
Collection|mixed cachedPermissions()

No description

Return Value

Collection|mixed

in RbacRoleTrait at line 34
static void boot()

No description

Return Value

void

in RbacRoleTrait at line 69
flushPermissionRole()

清理权限

in RbacRoleTrait at line 77
BelongsToMany users()

No description

Return Value

BelongsToMany

in RbacRoleTrait at line 96
BelongsToMany perms()

Many-to-Many relations with the permission model.

Named "perms" for backwards compatibility. Also, because "perms" is short and sweet.

Return Value

BelongsToMany

in RbacRoleTrait at line 112
void savePermissions($permissions)

No description

Parameters

$permissions

Return Value

void

in RbacRoleTrait at line 120
void syncPermission($id)

No description

Parameters

$id

Return Value

void

in RbacRoleTrait at line 133
void attachPermission(object|array|Permission $id)

给角色添加权限, 并且清空角色缓存

Parameters

object|array|Permission $id 权限

Return Value

void

in RbacRoleTrait at line 154
void detachPermission(object|array $id)

Detach permission from current role.

Parameters

object|array $id 权限ID

Return Value

void

in RbacRoleTrait at line 173
void attachPermissions(array $permissions)

No description

Parameters

array $permissions

Return Value

void

in RbacRoleTrait at line 183
void detachPermissions(array $permissions)

No description

Parameters

array $permissions

Return Value

void

in RbacRoleTrait at line 196
bool hasPermission(string|array $name, bool $require_all = false)

Checks if the role has a permission by its name.

Parameters

string|array $name

permission name or array of permission names

bool $require_all

all permissions in the array are required

Return Value

bool

in RbacRoleTrait at line 226
static protected void clearCachedPermissions()

No description

Return Value

void

in RbacRoleTrait at line 231
static protected void clearCachedPivotPermissions($role_id)

No description

Parameters

$role_id

Return Value

void

at line 50
static mixed getAccountTypeByRoleId(int $role_id)

通过角色来获取账户类型, 由于角色在单条处理中不会存在变化, 故而可以进行静态缓存

Parameters

int $role_id 角色id

Return Value

mixed

at line 66
static Collection getLinear(null|string $type = null, string $key = 'id')

返回一维的角色对应

Parameters

null|string $type 类型
string $key key

Return Value

Collection

at line 77
static array getAll(string|null $accountType = null, bool $cache = true)

根据账户类型获取角色

Parameters

string|null $accountType 账户类型
bool $cache 是否缓存

Return Value

array

at line 100
static null info(int $id, null $key = null, bool $cache = true)

获取角色信息

Parameters

int $id 角色id
null $key key
bool $cache 是否缓存

Return Value

null