W3cubDocs

/Laravel 5.8

Gate

interface Gate (View source)

Methods

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 = [])

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

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

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

bool check(iterable|string $abilities, array|mixed $arguments = [])

Determine if all of the given abilities should be granted for the current user.

bool any(iterable|string $abilities, array|mixed $arguments = [])

Determine if any one of the given abilities should be granted for the current user.

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

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

mixed raw(string $ability, array|mixed $arguments = [])

Get the raw result from the authorization callback.

mixed getPolicyFor(object|string $class)

Get a policy instance for a given class.

Gate forUser(Authenticatable|mixed $user)

Get a guard instance for the given user.

array abilities()

Get all of the defined abilities.

Details

bool has(string $ability)

Determine if a given ability has been defined.

Parameters

string $ability

Return Value

bool

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

Define a new ability.

Parameters

string $ability
callable|string $callback

Return Value

$this

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

Define a policy class for a given class type.

Parameters

string $class
string $policy

Return Value

$this

$this before(callable $callback)

Register a callback to run before all Gate checks.

Parameters

callable $callback

Return Value

$this

$this after(callable $callback)

Register a callback to run after all Gate checks.

Parameters

callable $callback

Return Value

$this

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

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

Parameters

string $ability
array|mixed $arguments

Return Value

bool

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

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

Parameters

string $ability
array|mixed $arguments

Return Value

bool

bool check(iterable|string $abilities, array|mixed $arguments = [])

Determine if all of the given abilities should be granted for the current user.

Parameters

iterable|string $abilities
array|mixed $arguments

Return Value

bool

bool any(iterable|string $abilities, array|mixed $arguments = [])

Determine if any one of the given abilities should be granted for the current user.

Parameters

iterable|string $abilities
array|mixed $arguments

Return Value

bool

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

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

Parameters

string $ability
array|mixed $arguments

Return Value

Response

Exceptions

AuthorizationException

mixed raw(string $ability, array|mixed $arguments = [])

Get the raw result from the authorization callback.

Parameters

string $ability
array|mixed $arguments

Return Value

mixed

mixed getPolicyFor(object|string $class)

Get a policy instance for a given class.

Parameters

object|string $class

Return Value

mixed

Exceptions

InvalidArgumentException

Gate forUser(Authenticatable|mixed $user)

Get a guard instance for the given user.

Parameters

Authenticatable|mixed $user

Return Value

Gate

array abilities()

Get all of the defined abilities.

Return Value

array

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.8/Illuminate/Contracts/Auth/Access/Gate.html