PHP Trait Artesaos\Defender\Traits\HasDefender

Inheritance: use trait Artesaos\Defender\Traits\Users\HasRoles, use trait Artesaos\Defender\Traits\Users\HasPermissions
Show file Open project: artesaos/defender

Public Methods

Method Description
canDo ( string $permission, boolean $force = false ) : boolean Checks for permission If has superuser group automatically passes.
findById ( integer $id ) : Artesaos\Defender\Contracts\User Find a user by its id.
getAllPermissions ( boolean $force = false ) : Collection Retrieve all user permissions.
getRolesPermissions ( boolean $force = false ) : Collection Get permissions from database based on roles.
hasPermission ( string $permission, boolean $force = false ) : boolean Returns if the current user has the given permission.
hasPermissions ( array $permissions, boolean $strict = true, boolean $force = false ) : boolean Returns if the current user has all or one permission of the given array.
isSuperUser ( ) : boolean check has superuser role.
roleHasPermission ( string $permission, boolean $force = false ) : boolean Check if the user has the given permission using only his roles.

Protected Methods

Method Description
getFreshAllPermissions ( ) : Collection Get fresh permissions from database.
getFreshRolesPermissions ( ) : Collection Get fresh permissions from database based on roles.

Method Details

canDo() public method

Checks for permission If has superuser group automatically passes.
public canDo ( string $permission, boolean $force = false ) : boolean
$permission string
$force boolean
return boolean

findById() public method

Find a user by its id.
public findById ( integer $id ) : Artesaos\Defender\Contracts\User
$id integer
return Artesaos\Defender\Contracts\User

getAllPermissions() public method

Retrieve all user permissions.
public getAllPermissions ( boolean $force = false ) : Collection
$force boolean
return Illuminate\Support\Collection

getFreshAllPermissions() protected method

Get fresh permissions from database.
protected getFreshAllPermissions ( ) : Collection
return Illuminate\Support\Collection

getFreshRolesPermissions() protected method

Get fresh permissions from database based on roles.
protected getFreshRolesPermissions ( ) : Collection
return Illuminate\Support\Collection

getRolesPermissions() public method

Get permissions from database based on roles.
public getRolesPermissions ( boolean $force = false ) : Collection
$force boolean
return Illuminate\Support\Collection

hasPermission() public method

User permissions override role permissions.
public hasPermission ( string $permission, boolean $force = false ) : boolean
$permission string
$force boolean
return boolean

hasPermissions() public method

User permissions override role permissions.
public hasPermissions ( array $permissions, boolean $strict = true, boolean $force = false ) : boolean
$permissions array Array of permissions
$strict boolean Check if has all permissions from array or one of them
$force boolean
return boolean

isSuperUser() public method

check has superuser role.
public isSuperUser ( ) : boolean
return boolean

roleHasPermission() public method

Check if the user has the given permission using only his roles.
public roleHasPermission ( string $permission, boolean $force = false ) : boolean
$permission string
$force boolean
return boolean