PHP 트레잇 Laratrust\Traits\LaratrustUserTrait

파일 보기 프로젝트 열기: santigarcor/laratrust

공개 메소드들

메소드 설명
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