Documentation

Gate

Table of Contents

abilities()  : array<string|int, mixed>
Get all of the defined abilities.
after()  : $this
Register a callback to run after all Gate checks.
allows()  : bool
Determine if the given ability should be granted for the current user.
any()  : bool
Determine if any one of the given abilities should be granted for the current user.
authorize()  : Response
Determine if the given ability should be granted for the current user.
before()  : $this
Register a callback to run before all Gate checks.
check()  : bool
Determine if all of the given abilities should be granted for the current user.
define()  : $this
Define a new ability.
denies()  : bool
Determine if the given ability should be denied for the current user.
forUser()  : static
Get a guard instance for the given user.
getPolicyFor()  : mixed
Get a policy instance for a given class.
has()  : bool
Determine if a given ability has been defined.
policy()  : $this
Define a policy class for a given class type.

Methods

abilities()

Get all of the defined abilities.

public abilities() : array<string|int, mixed>
Return values
array<string|int, mixed>

after()

Register a callback to run after all Gate checks.

public after(callable $callback) : $this
Parameters
$callback : callable
Return values
$this

allows()

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

public allows(string $ability[, array<string|int, mixed>|mixed $arguments = [] ]) : bool
Parameters
$ability : string
$arguments : array<string|int, mixed>|mixed = []
Return values
bool

any()

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

public any(iteratable<string|int, mixed>|string $abilities[, array<string|int, mixed>|mixed $arguments = [] ]) : bool
Parameters
$abilities : iteratable<string|int, mixed>|string
$arguments : array<string|int, mixed>|mixed = []
Return values
bool

authorize()

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

public authorize(string $ability[, array<string|int, mixed>|mixed $arguments = [] ]) : Response
Parameters
$ability : string
$arguments : array<string|int, mixed>|mixed = []
Tags
throws
AuthorizationException
Return values
Response

before()

Register a callback to run before all Gate checks.

public before(callable $callback) : $this
Parameters
$callback : callable
Return values
$this

check()

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

public check(iteratable<string|int, mixed>|string $abilities[, array<string|int, mixed>|mixed $arguments = [] ]) : bool
Parameters
$abilities : iteratable<string|int, mixed>|string
$arguments : array<string|int, mixed>|mixed = []
Return values
bool

define()

Define a new ability.

public define(string $ability, callable|string $callback) : $this
Parameters
$ability : string
$callback : callable|string
Return values
$this

denies()

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

public denies(string $ability[, array<string|int, mixed>|mixed $arguments = [] ]) : bool
Parameters
$ability : string
$arguments : array<string|int, mixed>|mixed = []
Return values
bool

getPolicyFor()

Get a policy instance for a given class.

public getPolicyFor(object|string $class) : mixed
Parameters
$class : object|string
Tags
throws
InvalidArgumentException
Return values
mixed

has()

Determine if a given ability has been defined.

public has(string $ability) : bool
Parameters
$ability : string
Return values
bool

policy()

Define a policy class for a given class type.

public policy(string $class, string $policy) : $this
Parameters
$class : string
$policy : string
Return values
$this

Search results