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 24
bool
has(array|UnitEnum|string $ability)
Determine if a given ability has been defined.
at line 33
Gate
define(UnitEnum|string $ability, array|callable|string $callback)
Define a new ability.
at line 41
Gate
resource(string $name, string $class, array|null $abilities = null)
Define abilities for a resource.
at line 49
Gate
policy(string $class, string $policy)
Define a policy class for a given class type.
at line 57
Gate
before(callable $callback)
Register a callback to run before all Gate checks.
at line 65
Gate
after(callable $callback)
Register a callback to run after all Gate checks.
at line 73
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 80
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 85
bool
allows(iterable|UnitEnum|string $ability, mixed $arguments = [])
Determine if all of the given abilities should be granted for the current user.
at line 90
bool
denies(iterable|UnitEnum|string $ability, mixed $arguments = [])
Determine if any of the given abilities should be denied for the current user.
at line 95
bool
check(iterable|UnitEnum|string $abilities, mixed $arguments = [])
Determine if all of the given abilities should be granted for the current user.
at line 100
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 105
bool
none(iterable|UnitEnum|string $abilities, mixed $arguments = [])
Determine if all of the given abilities should be denied for the current user.
at line 112
Response
authorize(UnitEnum|string $ability, mixed $arguments = [])
Determine if the given ability should be granted for the current user.
at line 117
Response
inspect(UnitEnum|string $ability, mixed $arguments = [])
Inspect the user for the given ability.
at line 124
mixed
raw(string $ability, mixed $arguments = [])
Get the raw result from the authorization callback.
at line 132
Builder
scope(UnitEnum|string $ability, Builder $query)
Apply the policy's scope method to filter a query to authorized rows.
at line 142
Expression|Builder
select(UnitEnum|string $ability, Builder|Model|string $query)
Get a scalar boolean selection from the policy for per-row authorization.
at line 147
mixed
getPolicyFor(object|string $class)
Get a policy instance for a given class.
at line 152
Gate
forUser(mixed $user)
Get a gate instance for the given user.
at line 157
array
abilities()
Get all of the defined abilities.