PHP Трейт Spatie\Permission\Traits\HasRoles

Наследование: use trait HasPermissions, use trait Spatie\Permission\Traits\RefreshesPermissionCache
Показать файл Открыть проект

Открытые методы

Метод Описание
assignRole ( $roles ) : Spatie\Permission\Contracts\Role Assign the given role to the user.
hasAllRoles ( string | Spatie\Permission\Contracts\Role | Collection $roles ) : boolean Determine if the user has all of the given role(s).
hasAnyRole ( string | array | Spatie\Permission\Contracts\Role | Collection $roles ) : boolean Determine if the user has any of the given role(s).
hasPermission ( Spatie\Permission\Contracts\Permission $permission ) : boolean
hasPermissionTo ( string | Spatie\Permission\Contracts\Permission $permission ) : boolean Determine if the user may perform the given permission.
hasRole ( string | array | Spatie\Permission\Contracts\Role | Collection $roles ) : boolean Determine if the user has (one of) the given role(s).
permissions ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany A user may have multiple direct permissions.
removeRole ( string | Spatie\Permission\Contracts\Role $role ) Revoke the given role from the user.
roles ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany A user may have multiple roles.
syncRoles ( $roles ) Remove all current roles and set the given ones.

Защищенные методы

Метод Описание
getStoredRole ( $role ) : Spatie\Permission\Contracts\Role
hasDirectPermission ( string | Spatie\Permission\Contracts\Permission $permission ) : boolean Determine if the user has the given permission.
hasPermissionViaRole ( Spatie\Permission\Contracts\Permission $permission ) : boolean Determine if the user has, via roles, the given permission.

Описание методов

assignRole() публичный Метод

Assign the given role to the user.
public assignRole ( $roles ) : Spatie\Permission\Contracts\Role
$roles
Результат Spatie\Permission\Contracts\Role

getStoredRole() защищенный Метод

protected getStoredRole ( $role ) : Spatie\Permission\Contracts\Role
$role
Результат Spatie\Permission\Contracts\Role

hasAllRoles() публичный Метод

Determine if the user has all of the given role(s).
public hasAllRoles ( string | Spatie\Permission\Contracts\Role | Collection $roles ) : boolean
$roles string | Spatie\Permission\Contracts\Role | Illuminate\Support\Collection
Результат boolean

hasAnyRole() публичный Метод

Determine if the user has any of the given role(s).
public hasAnyRole ( string | array | Spatie\Permission\Contracts\Role | Collection $roles ) : boolean
$roles string | array | Spatie\Permission\Contracts\Role | Illuminate\Support\Collection
Результат boolean

hasDirectPermission() защищенный Метод

Determine if the user has the given permission.
protected hasDirectPermission ( string | Spatie\Permission\Contracts\Permission $permission ) : boolean
$permission string | Spatie\Permission\Contracts\Permission
Результат boolean

hasPermission() публичный Метод

Устаревший: deprecated since version 1.0.1, use hasPermissionTo instead Determine if the user may perform the given permission.
public hasPermission ( Spatie\Permission\Contracts\Permission $permission ) : boolean
$permission Spatie\Permission\Contracts\Permission
Результат boolean

hasPermissionTo() публичный Метод

Determine if the user may perform the given permission.
public hasPermissionTo ( string | Spatie\Permission\Contracts\Permission $permission ) : boolean
$permission string | Spatie\Permission\Contracts\Permission
Результат boolean

hasPermissionViaRole() защищенный Метод

Determine if the user has, via roles, the given permission.
protected hasPermissionViaRole ( Spatie\Permission\Contracts\Permission $permission ) : boolean
$permission Spatie\Permission\Contracts\Permission
Результат boolean

hasRole() публичный Метод

Determine if the user has (one of) the given role(s).
public hasRole ( string | array | Spatie\Permission\Contracts\Role | Collection $roles ) : boolean
$roles string | array | Spatie\Permission\Contracts\Role | Illuminate\Support\Collection
Результат boolean

permissions() публичный Метод

A user may have multiple direct permissions.
public permissions ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
Результат Illuminate\Database\Eloquent\Relations\BelongsToMany

removeRole() публичный Метод

Revoke the given role from the user.
public removeRole ( string | Spatie\Permission\Contracts\Role $role )
$role string | Spatie\Permission\Contracts\Role

roles() публичный Метод

A user may have multiple roles.
public roles ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
Результат Illuminate\Database\Eloquent\Relations\BelongsToMany

syncRoles() публичный Метод

Remove all current roles and set the given ones.
public syncRoles ( $roles )
$roles