PHP Трейт App\Traits\UserHasPermissionsTrait

Показать файл Открыть проект

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

Метод Описание
attachPermission ( $permission ) Alias to eloquent many-to-many relation's attach() method.
attachPermissions ( mixed $permissions ) Attach multiple permissions to a user
boot ( ) : void | boolean Boot the user model Attach event listener to remove the many-to-many records when trying to delete Will NOT delete any records if the user model uses soft deletes.
can ( $permission, boolean $requireAll = false ) : boolean Overwrites EntrustUserTrait::can(.
canInRoles ( $permission, boolean $requireAll = false ) : boolean Code copy of EntrustUserTrait::can(.
detachPermission ( mixed $permission ) Alias to eloquent many-to-many relation's detach() method.
detachPermissions ( mixed $permissions ) Detach multiple permissions from a user
hasPermission ( string | array $name, boolean $requireAll = false ) : boolean Checks if the user has a permission by its name.
permissions ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany Many-to-Many relations with Permission.

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

attachPermission() публичный метод

Alias to eloquent many-to-many relation's attach() method.
public attachPermission ( $permission )

attachPermissions() публичный метод

Attach multiple permissions to a user
public attachPermissions ( mixed $permissions )
$permissions mixed

boot() публичный статический метод

Boot the user model Attach event listener to remove the many-to-many records when trying to delete Will NOT delete any records if the user model uses soft deletes.
public static boot ( ) : void | boolean
Результат void | boolean

can() публичный метод

..), first checks if the permission(s) are directly associated to the user model, using ->hasPermission(), then may if required check if permission(s) are associated through the roles, using ->canInRole().
public can ( $permission, boolean $requireAll = false ) : boolean
$permission
$requireAll boolean
Результат boolean

canInRoles() публичный метод

..) with the one addition to check if a role is enabled first the check if a permission is also enabled before returning true.
public canInRoles ( $permission, boolean $requireAll = false ) : boolean
$permission
$requireAll boolean
Результат boolean

detachPermission() публичный метод

Alias to eloquent many-to-many relation's detach() method.
public detachPermission ( mixed $permission )
$permission mixed

detachPermissions() публичный метод

Detach multiple permissions from a user
public detachPermissions ( mixed $permissions )
$permissions mixed

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

Checks if the user has a permission by its name.
public hasPermission ( string | array $name, boolean $requireAll = false ) : boolean
$name string | array Permission name or array of permission names.
$requireAll boolean All roles in the array are required.
Результат boolean

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

Many-to-Many relations with Permission.
public permissions ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
Результат Illuminate\Database\Eloquent\Relations\BelongsToMany