interface Gate (View source)

Methods

bool
has(UnitEnum|string $ability)

Determine if a given ability has been defined.

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

Define a new ability.

$this
resource(string $name, string $class, array|null $abilities = null)

Define abilities for a resource.

$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(iterable|UnitEnum|string $ability, mixed $arguments = [])

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

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

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

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

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

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

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

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

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

inspect(UnitEnum|string $ability, mixed $arguments = [])

Inspect the user for the given ability.

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

Get the raw result from the authorization callback.

mixed
getPolicyFor(object|string $class)

Get a policy instance for a given class.

forUser(Authenticatable|mixed $user)

Get a guard instance for the given user.

array
abilities()

Get all of the defined abilities.

Details

bool has(UnitEnum|string $ability)

Determine if a given ability has been defined.

Parameters

UnitEnum|string $ability

Return Value

bool

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

Define a new ability.

Parameters

UnitEnum|string $ability
callable|string $callback

Return Value

$this

$this resource(string $name, string $class, array|null $abilities = null)

Define abilities for a resource.

Parameters

string $name
string $class
array|null $abilities

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(iterable|UnitEnum|string $ability, mixed $arguments = [])

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

Parameters

iterable|UnitEnum|string $ability
mixed $arguments

Return Value

bool

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

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

Parameters

iterable|UnitEnum|string $ability
mixed $arguments

Return Value

bool

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

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

Parameters

iterable|UnitEnum|string $abilities
mixed $arguments

Return Value

bool

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

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

Parameters

iterable|UnitEnum|string $abilities
mixed $arguments

Return Value

bool

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

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

Parameters

UnitEnum|string $ability
mixed $arguments

Return Value

Response

Exceptions

AuthorizationException

Response inspect(UnitEnum|string $ability, mixed $arguments = [])

Inspect the user for the given ability.

Parameters

UnitEnum|string $ability
mixed $arguments

Return Value

Response

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

Get the raw result from the authorization callback.

Parameters

string $ability
mixed $arguments

Return Value

mixed

Exceptions

AuthorizationException

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

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.