class Gate implements Gate (View source)

Traits

Methods

void
__construct( Container $container, callable $userResolver, array $abilities = array(), array $policies = array(), array $beforeCallbacks = array(), array $afterCallbacks = array())

Create a new gate instance.

bool
has( string $ability)

Determine if a given ability has been defined.

$this
define( string $ability, callable|string $callback)

Define a new ability.

$this
policy( string $class, string $policy)

Define a policy class for a given class type.

$this
before( callable $callback)

Register a callback to run before all Gate checks.

$this
after( callable $callback)

Register a callback to run after all Gate checks.

bool
allows( string $ability, array|mixed $arguments = array())

Determine if the given ability should be granted for the current user.

bool
denies( string $ability, array|mixed $arguments = array())

Determine if the given ability should be denied for the current user.

bool
check( string $ability, array|mixed $arguments = array())

Determine if the given ability should be granted for the current user.

authorize( string $ability, array|mixed $arguments = array())

Determine if the given ability should be granted for the current user.

mixed
getPolicyFor( object|string $class)

Get a policy instance for a given class.

mixed
resolvePolicy( object|string $class)

Build a policy class instance of the given type.

forUser( Authenticatable|mixed $user)

Get a guard instance for the given user.

Details

at line line 67
void __construct( Container $container, callable $userResolver, array $abilities = array(), array $policies = array(), array $beforeCallbacks = array(), array $afterCallbacks = array())

Create a new gate instance.

Parameters

Container $container
callable $userResolver
array $abilities
array $policies
array $beforeCallbacks
array $afterCallbacks

Return Value

void

at line line 83
bool has( string $ability)

Determine if a given ability has been defined.

Parameters

string $ability

Return Value

bool

at line line 97
$this define( string $ability, callable|string $callback)

Define a new ability.

Parameters

string $ability
callable|string $callback

Return Value

$this

Exceptions

InvalidArgumentException

at line line 132
$this policy( string $class, string $policy)

Define a policy class for a given class type.

Parameters

string $class
string $policy

Return Value

$this

at line line 145
$this before( callable $callback)

Register a callback to run before all Gate checks.

Parameters

callable $callback

Return Value

$this

at line line 158
$this after( callable $callback)

Register a callback to run after all Gate checks.

Parameters

callable $callback

Return Value

$this

at line line 172
bool allows( string $ability, array|mixed $arguments = array())

Determine if the given ability should be granted for the current user.

Parameters

string $ability
array|mixed $arguments

Return Value

bool

at line line 184
bool denies( string $ability, array|mixed $arguments = array())

Determine if the given ability should be denied for the current user.

Parameters

string $ability
array|mixed $arguments

Return Value

bool

at line line 196
bool check( string $ability, array|mixed $arguments = array())

Determine if the given ability should be granted for the current user.

Parameters

string $ability
array|mixed $arguments

Return Value

bool

at line line 216
Response authorize( string $ability, array|mixed $arguments = array())

Determine if the given ability should be granted for the current user.

Parameters

string $ability
array|mixed $arguments

Return Value

Response

Exceptions

AuthorizationException

at line line 402
mixed getPolicyFor( object|string $class)

Get a policy instance for a given class.

Parameters

object|string $class

Return Value

mixed

Exceptions

InvalidArgumentException

at line line 421
mixed resolvePolicy( object|string $class)

Build a policy class instance of the given type.

Parameters

object|string $class

Return Value

mixed

at line line 432
Gate forUser( Authenticatable|mixed $user)

Get a guard instance for the given user.

Parameters

Authenticatable|mixed $user

Return Value

Gate