PHP Trait Silber\Bouncer\Database\HasRoles

Show file Open project: JosephSilber/bouncer

Public Methods

Method Description
assign ( Role | string $role ) Assign the given role to the model.
isA ( string $role ) : boolean Check if the model has any of the given roles.
isAll ( string $role ) : boolean Check if the model has all of the given roles.
isAn ( string $role ) : boolean Check if the model has any of the given roles.
isNot ( string $role ) : boolean Check if the model has none of the given roles.
isNotA ( string $role ) : boolean Check if the model has none of the given roles.
isNotAn ( string $role ) : boolean Check if the model has none of the given roles.
retract ( Role | string $role ) Retract the given role from the model.
roles ( ) : Illuminate\Database\Eloquent\Relations\MorphToMany The roles relationship.
scopeWhereIs ( Builder $query, string $role ) : void Constrain the given query by the provided role.
scopeWhereIsAll ( Builder $query, string $role ) : void Constrain the given query by all provided roles.

Protected Methods

Method Description
getClipboardInstance ( ) : Clipboard Get an instance of the bouncer's clipboard.

Method Details

assign() public method

Assign the given role to the model.
public assign ( Role | string $role )
$role Role | string

getClipboardInstance() protected method

Get an instance of the bouncer's clipboard.
protected getClipboardInstance ( ) : Clipboard
return Silber\Bouncer\Clipboard

isA() public method

Alias for the "isAn" method.
public isA ( string $role ) : boolean
$role string
return boolean

isAll() public method

Check if the model has all of the given roles.
public isAll ( string $role ) : boolean
$role string
return boolean

isAn() public method

Check if the model has any of the given roles.
public isAn ( string $role ) : boolean
$role string
return boolean

isNot() public method

Alias for the "isNotAn" method.
public isNot ( string $role ) : boolean
$role string
return boolean

isNotA() public method

Alias for the "isNotAn" method.
public isNotA ( string $role ) : boolean
$role string
return boolean

isNotAn() public method

Check if the model has none of the given roles.
public isNotAn ( string $role ) : boolean
$role string
return boolean

retract() public method

Retract the given role from the model.
public retract ( Role | string $role )
$role Role | string

roles() public method

The roles relationship.
public roles ( ) : Illuminate\Database\Eloquent\Relations\MorphToMany
return Illuminate\Database\Eloquent\Relations\MorphToMany

scopeWhereIs() public method

Constrain the given query by the provided role.
public scopeWhereIs ( Builder $query, string $role ) : void
$query Illuminate\Database\Eloquent\Builder
$role string
return void

scopeWhereIsAll() public method

Constrain the given query by all provided roles.
public scopeWhereIsAll ( Builder $query, string $role ) : void
$query Illuminate\Database\Eloquent\Builder
$role string
return void