PHP Trait app\Models\Access\User\Traits\UserAccess

Show file Open project: rappasoft/laravel-5-boilerplate

Public Methods

Method Description
allow ( string $nameOrId ) : boolean Check if user has a permission by its name or id.
allowMultiple ( $permissions, $needsAll = false ) : boolean Check an array of permissions and whether or not all are required to continue
attachRole ( mixed $role ) : void Alias to eloquent many-to-many relation's attach() method.
attachRoles ( mixed $roles ) : void Attach multiple roles to a user
detachRole ( mixed $role ) : void Alias to eloquent many-to-many relation's detach() method.
detachRoles ( mixed $roles ) : void Detach multiple roles from a user
hasPermission ( $nameOrId ) : boolean
hasPermissions ( $permissions, boolean $needsAll = false ) : boolean
hasRole ( string $nameOrId ) : boolean Checks if the user has a Role by its name or id.
hasRoles ( $roles, $needsAll = false ) : boolean Checks to see if user has array of roles

Method Details

allow() public method

Check if user has a permission by its name or id.
public allow ( string $nameOrId ) : boolean
$nameOrId string Permission name or id.
return boolean

allowMultiple() public method

Check an array of permissions and whether or not all are required to continue
public allowMultiple ( $permissions, $needsAll = false ) : boolean
$permissions
$needsAll
return boolean

attachRole() public method

Alias to eloquent many-to-many relation's attach() method.
public attachRole ( mixed $role ) : void
$role mixed
return void

attachRoles() public method

Attach multiple roles to a user
public attachRoles ( mixed $roles ) : void
$roles mixed
return void

detachRole() public method

Alias to eloquent many-to-many relation's detach() method.
public detachRole ( mixed $role ) : void
$role mixed
return void

detachRoles() public method

Detach multiple roles from a user
public detachRoles ( mixed $roles ) : void
$roles mixed
return void

hasPermission() public method

public hasPermission ( $nameOrId ) : boolean
$nameOrId
return boolean

hasPermissions() public method

public hasPermissions ( $permissions, boolean $needsAll = false ) : boolean
$permissions
$needsAll boolean
return boolean

hasRole() public method

Checks if the user has a Role by its name or id.
public hasRole ( string $nameOrId ) : boolean
$nameOrId string Role name or id.
return boolean

hasRoles() public method

All must return true
public hasRoles ( $roles, $needsAll = false ) : boolean
$roles
$needsAll
return boolean