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 23
bool
has(array|UnitEnum|string $ability)
Determine if a given ability has been defined.
at line 30
Gate
define(UnitEnum|string $ability, array|callable|string $callback)
Define a new ability.
at line 35
Gate
resource(string $name, string $class, array|null $abilities = null)
Define abilities for a resource.
at line 40
Gate
policy(string $class, string $policy)
Define a policy class for a given class type.
at line 45
Gate
before(callable $callback)
Register a callback to run before all Gate checks.
at line 50
Gate
after(callable $callback)
Register a callback to run after all Gate checks.
at line 57
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 64
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 69
bool
allows(iterable|UnitEnum|string $ability, mixed $arguments = [])
Determine if all of the given abilities should be granted for the current user.
at line 74
bool
denies(iterable|UnitEnum|string $ability, mixed $arguments = [])
Determine if any of the given abilities should be denied for the current user.
at line 79
bool
check(iterable|UnitEnum|string $abilities, mixed $arguments = [])
Determine if all of the given abilities should be granted for the current user.
at line 84
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 89
bool
none(iterable|UnitEnum|string $abilities, mixed $arguments = [])
Determine if all of the given abilities should be denied for the current user.
at line 96
Response
authorize(UnitEnum|string $ability, mixed $arguments = [])
Determine if the given ability should be granted for the current user.
at line 101
Response
inspect(UnitEnum|string $ability, mixed $arguments = [])
Inspect the user for the given ability.
at line 108
mixed
raw(string $ability, mixed $arguments = [])
Get the raw result from the authorization callback.
at line 116
Builder
scope(UnitEnum|string $ability, Builder $query)
Apply the policy's scope method to filter a query to authorized rows.
at line 126
Expression|Builder
select(UnitEnum|string $ability, Builder|Model|string $query)
Get a scalar boolean selection from the policy for per-row authorization.
at line 131
mixed
getPolicyFor(object|string $class)
Get a policy instance for a given class.
at line 136
Gate
forUser(mixed $user)
Get a gate instance for the given user.
at line 141
array
abilities()
Get all of the defined abilities.