trait AuthorizesRequests (View source)

Methods

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

Authorize a given action for the current user.

authorizeForUser(Authenticatable|mixed $user, mixed $ability, mixed|array $arguments = [])

Authorize a given action for a user.

array
parseAbilityAndArguments(mixed $ability, mixed|array $arguments)

Guesses the ability's name if it wasn't provided.

string
normalizeGuessedAbilityName(string $ability)

Normalize the ability name that has been guessed from the method name.

void
authorizeResource(string|array $model, string|array|null $parameter = null, array $options = [], Request|null $request = null)

Authorize a resource action based on the incoming request.

array<string,string>
resourceAbilityMap()

Get the map of resource methods to ability names.

list<string>
resourceMethodsWithoutModels()

Get the list of resource methods which do not have model parameters.

Details

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

Authorize a given action for the current user.

Parameters

mixed $ability
mixed|array $arguments

Return Value

Response

Exceptions

AuthorizationException

Response authorizeForUser(Authenticatable|mixed $user, mixed $ability, mixed|array $arguments = [])

Authorize a given action for a user.

Parameters

Authenticatable|mixed $user
mixed $ability
mixed|array $arguments

Return Value

Response

Exceptions

AuthorizationException

protected array parseAbilityAndArguments(mixed $ability, mixed|array $arguments)

Guesses the ability's name if it wasn't provided.

Parameters

mixed $ability
mixed|array $arguments

Return Value

array

protected string normalizeGuessedAbilityName(string $ability)

Normalize the ability name that has been guessed from the method name.

Parameters

string $ability

Return Value

string

void authorizeResource(string|array $model, string|array|null $parameter = null, array $options = [], Request|null $request = null)

Authorize a resource action based on the incoming request.

Parameters

string|array $model
string|array|null $parameter
array $options
Request|null $request

Return Value

void

protected array<string,string> resourceAbilityMap()

Get the map of resource methods to ability names.

Return Value

array<string,string>

protected list<string> resourceMethodsWithoutModels()

Get the list of resource methods which do not have model parameters.

Return Value

list<string>