Skip to content

[13.x] Support enum model arguments in authorize middleware definitions#60270

Open
Tresor-Kasenda wants to merge 1 commit into
laravel:13.xfrom
Tresor-Kasenda:authorize-attribute-enum-models
Open

[13.x] Support enum model arguments in authorize middleware definitions#60270
Tresor-Kasenda wants to merge 1 commit into
laravel:13.xfrom
Tresor-Kasenda:authorize-attribute-enum-models

Conversation

@Tresor-Kasenda
Copy link
Copy Markdown
Contributor

Allows enum values to be used for model arguments when generating authorize middleware definitions.

Authorize::using() already supports enum values for the ability name. This change extends the same normalization to the model arguments, allowing code such as controller #[Authorize] attributes to pass enum-backed route parameter names or model references consistently.

The controller Authorize attribute type declaration has also been updated so models may be provided as a UnitEnum, string, array, or null.

## Description

This pull request allows enum values to be used for model arguments when generating authorize middleware definitions.

`Authorize::using()` already supports enum values for the ability name. This change extends the same normalization to the model arguments, allowing code such as controller `#[Authorize]` attributes to pass enum-backed route parameter names or model references consistently.

The controller `Authorize` attribute type declaration has also been updated so `models` may be provided as a `UnitEnum`, string, array, or null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant