Gate
interface Gate
Methods
Determine if a given ability has been defined.
Define abilities for a resource.
Perform an on-demand authorization check. Throw an authorization exception if the condition or callback is false.
Perform an on-demand authorization check. Throw an authorization exception if the condition or callback is true.
Determine if all of the given abilities should be granted for the current user.
Determine if any of the given abilities should be denied for the current user.
Determine if all of the given abilities should be granted for the current user.
Determine if any one of the given abilities should be granted for the current user.
Determine if all of the given abilities should be denied for the current user.
Determine if the given ability should be granted for the current user.
Inspect the user for the given ability.
Get the raw result from the authorization callback.
Get a policy instance for a given class.
Get all of the defined abilities.
Details
at line 21
bool
has(array|UnitEnum|string $ability)
Determine if a given ability has been defined.
at line 28
Gate
define(UnitEnum|string $ability, array|callable|string $callback)
Define a new ability.
at line 33
Gate
resource(string $name, string $class, array|null $abilities = null)
Define abilities for a resource.
at line 38
Gate
policy(string $class, string $policy)
Define a policy class for a given class type.
at line 43
Gate
before(callable $callback)
Register a callback to run before all Gate checks.
at line 48
Gate
after(callable $callback)
Register a callback to run after all Gate checks.
at line 55
Response
allowIf(mixed $condition, string|null $message = null, int|string|null $code = null)
Perform an on-demand authorization check. Throw an authorization exception if the condition or callback is false.
at line 62
Response
denyIf(mixed $condition, string|null $message = null, int|string|null $code = null)
Perform an on-demand authorization check. Throw an authorization exception if the condition or callback is true.
at line 67
bool
allows(iterable|UnitEnum|string $ability, mixed $arguments = [])
Determine if all of the given abilities should be granted for the current user.
at line 72
bool
denies(iterable|UnitEnum|string $ability, mixed $arguments = [])
Determine if any of the given abilities should be denied for the current user.
at line 77
bool
check(iterable|UnitEnum|string $abilities, mixed $arguments = [])
Determine if all of the given abilities should be granted for the current user.
at line 82
bool
any(iterable|UnitEnum|string $abilities, mixed $arguments = [])
Determine if any one of the given abilities should be granted for the current user.
at line 87
bool
none(iterable|UnitEnum|string $abilities, mixed $arguments = [])
Determine if all of the given abilities should be denied for the current user.
at line 94
Response
authorize(UnitEnum|string $ability, mixed $arguments = [])
Determine if the given ability should be granted for the current user.
at line 99
Response
inspect(UnitEnum|string $ability, mixed $arguments = [])
Inspect the user for the given ability.
at line 106
mixed
raw(string $ability, mixed $arguments = [])
Get the raw result from the authorization callback.
at line 113
Builder
scope(string $ability, Builder $query)
Apply the policy's scope method to filter a query to authorized rows.
at line 122
Expression
select(string $ability, Builder|Model|string $query)
Get a SQL expression from the policy for per-row authorization.
at line 127
mixed
getPolicyFor(object|string $class)
Get a policy instance for a given class.
at line 132
Gate
forUser(mixed $user)
Get a gate instance for the given user.
at line 137
array
abilities()
Get all of the defined abilities.