PHP Трейт Laratrust\Traits\LaratrustUserTrait

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

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

Метод Описание
ability ( string | array $roles, string | array $permissions, $group = null, array $options = [] ) : array | boolean Checks role(s) and permission(s).
attachPermission ( mixed $permission ) : Illuminate\Database\Eloquent\Model Alias to eloquent many-to-many relation's attach() method.
attachPermissions ( mixed $permissions ) : Illuminate\Database\Eloquent\Model Attach multiple permissions to a user
attachRole ( mixed $role, $group = null ) : Illuminate\Database\Eloquent\Model Alias to eloquent many-to-many relation's attach() method.
attachRoles ( mixed $roles, $group = null ) : Illuminate\Database\Eloquent\Model Attach multiple roles to a user
bootLaratrustUserTrait ( ) : 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.
cachedPermissions ( ) : Illuminate\Database\Eloquent\Collection Tries to return all the cached permissions of the user and if it can't bring the permissions from the cache, it would bring them back from the DB
cachedRoles ( ) : Illuminate\Database\Eloquent\Collection Tries to return all the cached roles of the user and if it can't bring the roles from the cache, it would bring them back from the DB
can ( string | array $permission, string | boolean $group = null, boolean $requireAll = false ) : boolean Check if user has a permission by its name.
detachPermission ( mixed $permission ) : Illuminate\Database\Eloquent\Model Alias to eloquent many-to-many relation's detach() method.
detachPermissions ( mixed $permissions = null ) : Illuminate\Database\Eloquent\Model Detach multiple permissions from a user
detachRole ( mixed $role, $group = null ) : Illuminate\Database\Eloquent\Model Alias to eloquent many-to-many relation's detach() method.
detachRoles ( mixed $roles = null, $group = null ) : Illuminate\Database\Eloquent\Model Detach multiple roles from a user
flushCache ( ) : void Flush the user's cache
groups ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany Many-to-Many relations with Group.
hasRole ( string | array $name, string | boolean $group = null, boolean $requireAll = false ) : boolean Checks if the user has a role by its name.
owns ( Model $thing ) : boolean Checks if the user owns the thing
permissions ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany Many-to-Many relations with Permission.
roles ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany Many-to-Many relations with Role.
scopeWherePermissionIs ( Illuminate\Database\Eloquent\Builder $query, string $permission = '' ) : Illuminate\Database\Eloquent\Builder This scope allows to retrive users with an specific permission
scopeWhereRoleIs ( Illuminate\Database\Eloquent\Builder $query, string $role = '' ) : Illuminate\Database\Eloquent\Builder This scope allows to retrive users with an specific role

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

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

Checks role(s) and permission(s).
public ability ( string | array $roles, string | array $permissions, $group = null, array $options = [] ) : array | boolean
$roles string | array Array of roles or comma separated string
$permissions string | array Array of permissions or comma separated string.
$options array validate_all (true|false) or return_type (boolean|array|both)
Результат array | boolean

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

Alias to eloquent many-to-many relation's attach() method.
public attachPermission ( mixed $permission ) : Illuminate\Database\Eloquent\Model
$permission mixed
Результат Illuminate\Database\Eloquent\Model

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

Attach multiple permissions to a user
public attachPermissions ( mixed $permissions ) : Illuminate\Database\Eloquent\Model
$permissions mixed
Результат Illuminate\Database\Eloquent\Model

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

Alias to eloquent many-to-many relation's attach() method.
public attachRole ( mixed $role, $group = null ) : Illuminate\Database\Eloquent\Model
$role mixed
Результат Illuminate\Database\Eloquent\Model

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

Attach multiple roles to a user
public attachRoles ( mixed $roles, $group = null ) : Illuminate\Database\Eloquent\Model
$roles mixed
Результат Illuminate\Database\Eloquent\Model

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

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 bootLaratrustUserTrait ( ) : void | boolean
Результат void | boolean

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

Tries to return all the cached permissions of the user and if it can't bring the permissions from the cache, it would bring them back from the DB
public cachedPermissions ( ) : Illuminate\Database\Eloquent\Collection
Результат Illuminate\Database\Eloquent\Collection

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

Tries to return all the cached roles of the user and if it can't bring the roles from the cache, it would bring them back from the DB
public cachedRoles ( ) : Illuminate\Database\Eloquent\Collection
Результат Illuminate\Database\Eloquent\Collection

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

Check if user has a permission by its name.
public can ( string | array $permission, string | boolean $group = null, boolean $requireAll = false ) : boolean
$permission string | array Permission string or array of permissions.
$group string | boolean Group name or requiredAll roles.
$requireAll boolean All permissions in the array are required.
Результат boolean

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

Alias to eloquent many-to-many relation's detach() method.
public detachPermission ( mixed $permission ) : Illuminate\Database\Eloquent\Model
$permission mixed
Результат Illuminate\Database\Eloquent\Model

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

Detach multiple permissions from a user
public detachPermissions ( mixed $permissions = null ) : Illuminate\Database\Eloquent\Model
$permissions mixed
Результат Illuminate\Database\Eloquent\Model

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

Alias to eloquent many-to-many relation's detach() method.
public detachRole ( mixed $role, $group = null ) : Illuminate\Database\Eloquent\Model
$role mixed
Результат Illuminate\Database\Eloquent\Model

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

Detach multiple roles from a user
public detachRoles ( mixed $roles = null, $group = null ) : Illuminate\Database\Eloquent\Model
$roles mixed
Результат Illuminate\Database\Eloquent\Model

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

Flush the user's cache
public flushCache ( ) : void
Результат void

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

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

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

Checks if the user has a role by its name.
public hasRole ( string | array $name, string | boolean $group = null, boolean $requireAll = false ) : boolean
$name string | array Role name or array of role names.
$group string | boolean Group name or requiredAll roles.
$requireAll boolean All roles in the array are required.
Результат boolean

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

Checks if the user owns the thing
public owns ( Model $thing ) : boolean
$thing Model
Результат boolean

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

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

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

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

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

This scope allows to retrive users with an specific permission
public scopeWherePermissionIs ( Illuminate\Database\Eloquent\Builder $query, string $permission = '' ) : Illuminate\Database\Eloquent\Builder
$query Illuminate\Database\Eloquent\Builder
$permission string
Результат Illuminate\Database\Eloquent\Builder

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

This scope allows to retrive users with an specific role
public scopeWhereRoleIs ( Illuminate\Database\Eloquent\Builder $query, string $role = '' ) : Illuminate\Database\Eloquent\Builder
$query Illuminate\Database\Eloquent\Builder
$role string
Результат Illuminate\Database\Eloquent\Builder