PHP Class Silber\Bouncer\Bouncer

Show file Open project: JosephSilber/bouncer Class Usage Examples

Protected Properties

Property Type Description
$clipboard Silber\Bouncer\Contracts\Clipboard The bouncer clipboard instance.
$gate Illuminate\Contracts\Auth\Access\Gate | null The access gate instance.

Public Methods

Method Description
__construct ( Silber\Bouncer\Contracts\Clipboard $clipboard ) Constructor.
ability ( array $attributes = [] ) : Ability Get an instance of the ability model.
allow ( Model | string $authority ) : GivesAbility Start a chain, to allow the given authority an ability.
allows ( string $ability, array | mixed $arguments = [] ) : boolean Determine if the given ability should be granted for the current authority.
assign ( Role | string $role ) : AssignsRole Start a chain, to assign the given role to a model.
cache ( Illuminate\Contracts\Cache\Store $cache = null ) Use the given cache instance.
create ( Model $user = null ) : static Create a new Bouncer instance.
define ( string $ability, callable | string $callback ) Define a new ability using a callback.
denies ( string $ability, array | mixed $arguments = [] ) : boolean Determine if the given ability should be denied for the current authority.
disallow ( Model | string $authority ) : RemovesAbility Start a chain, to disallow the given authority an ability.
dontCache ( ) Fully disable all query caching.
forbid ( Model | string $authority ) : GivesAbility Start a chain, to forbid the given authority an ability.
getGate ( $throw = false ) : Illuminate\Contracts\Auth\Access\Gate | null Get the gate instance.
is ( Model $authority ) : ChecksRole Start a chain, to check if the given authority has a certain role.
make ( Model $user = null ) : Silber\Bouncer\Factory. Create a bouncer factory instance.
ownedVia ( string | Closure $model, string | Closure | null $attribute = null ) : void Register an attribute/callback to determine if a model is owned by a given authority.
refresh ( Model $authority = null ) Clear the cache.
refreshFor ( Model $authority ) Clear the cache for the given authority.
retract ( Role | string $role ) : RemovesRole Start a chain, to retract the given role from a model.
role ( array $attributes = [] ) : Role Get an instance of the role model.
seed ( ) Run the registered seeders.
seeder ( Closure | string $seeder ) Register a seeder callback.
setGate ( Illuminate\Contracts\Auth\Access\Gate $gate ) Set the access gate instance.
tables ( array $map ) : void Set custom table names.
unforbid ( Model | string $authority ) : RemovesAbility Start a chain, to unforbid the given authority an ability.
useAbilityModel ( string $model ) Set the model to be used for abilities.
useRoleModel ( string $model ) Set the model to be used for roles.
useUserModel ( string $model ) Set the model to be used for users.
usesCachedClipboard ( ) : boolean Determine whether the clipboard used is a cached clipboard.

Protected Methods

Method Description
resolve ( string $abstract, array $parameters = [] ) : mixed Resolve the given type from the container.

Method Details

__construct() public method

Constructor.
public __construct ( Silber\Bouncer\Contracts\Clipboard $clipboard )
$clipboard Silber\Bouncer\Contracts\Clipboard

ability() public method

Get an instance of the ability model.
public ability ( array $attributes = [] ) : Ability
$attributes array
return Silber\Bouncer\Database\Ability

allow() public method

Start a chain, to allow the given authority an ability.
public allow ( Model | string $authority ) : GivesAbility
$authority Illuminate\Database\Eloquent\Model | string
return Silber\Bouncer\Conductors\GivesAbility

allows() public method

Determine if the given ability should be granted for the current authority.
public allows ( string $ability, array | mixed $arguments = [] ) : boolean
$ability string
$arguments array | mixed
return boolean

assign() public method

Start a chain, to assign the given role to a model.
public assign ( Role | string $role ) : AssignsRole
$role Silber\Bouncer\Database\Role | string
return Silber\Bouncer\Conductors\AssignsRole

cache() public method

Use the given cache instance.
public cache ( Illuminate\Contracts\Cache\Store $cache = null )
$cache Illuminate\Contracts\Cache\Store

create() public static method

Create a new Bouncer instance.
public static create ( Model $user = null ) : static
$user Illuminate\Database\Eloquent\Model
return static

define() public method

Define a new ability using a callback.
public define ( string $ability, callable | string $callback )
$ability string
$callback callable | string

denies() public method

Determine if the given ability should be denied for the current authority.
public denies ( string $ability, array | mixed $arguments = [] ) : boolean
$ability string
$arguments array | mixed
return boolean

disallow() public method

Start a chain, to disallow the given authority an ability.
public disallow ( Model | string $authority ) : RemovesAbility
$authority Illuminate\Database\Eloquent\Model | string
return Silber\Bouncer\Conductors\RemovesAbility

dontCache() public method

Fully disable all query caching.
public dontCache ( )

forbid() public method

Start a chain, to forbid the given authority an ability.
public forbid ( Model | string $authority ) : GivesAbility
$authority Illuminate\Database\Eloquent\Model | string
return Silber\Bouncer\Conductors\GivesAbility

getGate() public method

Get the gate instance.
public getGate ( $throw = false ) : Illuminate\Contracts\Auth\Access\Gate | null
return Illuminate\Contracts\Auth\Access\Gate | null

is() public method

Start a chain, to check if the given authority has a certain role.
public is ( Model $authority ) : ChecksRole
$authority Illuminate\Database\Eloquent\Model
return Silber\Bouncer\Conductors\ChecksRole

make() public static method

Create a bouncer factory instance.
public static make ( Model $user = null ) : Silber\Bouncer\Factory.
$user Illuminate\Database\Eloquent\Model
return Silber\Bouncer\Factory.

ownedVia() public method

Register an attribute/callback to determine if a model is owned by a given authority.
public ownedVia ( string | Closure $model, string | Closure | null $attribute = null ) : void
$model string | Closure
$attribute string | Closure | null
return void

refresh() public method

Clear the cache.
public refresh ( Model $authority = null )
$authority Illuminate\Database\Eloquent\Model

refreshFor() public method

Clear the cache for the given authority.
public refreshFor ( Model $authority )
$authority Illuminate\Database\Eloquent\Model

resolve() protected method

Resolve the given type from the container.
protected resolve ( string $abstract, array $parameters = [] ) : mixed
$abstract string
$parameters array
return mixed

retract() public method

Start a chain, to retract the given role from a model.
public retract ( Role | string $role ) : RemovesRole
$role Silber\Bouncer\Database\Role | string
return Silber\Bouncer\Conductors\RemovesRole

role() public method

Get an instance of the role model.
public role ( array $attributes = [] ) : Role
$attributes array
return Silber\Bouncer\Database\Role

seed() public method

Run the registered seeders.
public seed ( )

seeder() public method

Register a seeder callback.
public seeder ( Closure | string $seeder )
$seeder Closure | string

setGate() public method

Set the access gate instance.
public setGate ( Illuminate\Contracts\Auth\Access\Gate $gate )
$gate Illuminate\Contracts\Auth\Access\Gate

tables() public static method

Set custom table names.
public static tables ( array $map ) : void
$map array
return void

unforbid() public method

Start a chain, to unforbid the given authority an ability.
public unforbid ( Model | string $authority ) : RemovesAbility
$authority Illuminate\Database\Eloquent\Model | string
return Silber\Bouncer\Conductors\RemovesAbility

useAbilityModel() public static method

Set the model to be used for abilities.
public static useAbilityModel ( string $model )
$model string

useRoleModel() public static method

Set the model to be used for roles.
public static useRoleModel ( string $model )
$model string

useUserModel() public static method

Set the model to be used for users.
public static useUserModel ( string $model )
$model string

usesCachedClipboard() public method

Determine whether the clipboard used is a cached clipboard.
public usesCachedClipboard ( ) : boolean
return boolean

Property Details

$clipboard protected property

The bouncer clipboard instance.
protected Clipboard,Silber\Bouncer\Contracts $clipboard
return Silber\Bouncer\Contracts\Clipboard

$gate protected property

The access gate instance.
protected Gate,Illuminate\Contracts\Auth\Access|null $gate
return Illuminate\Contracts\Auth\Access\Gate | null