Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@elbojoloco
Copy link
Contributor

Enables you to provide a default value when retrieving an enum from data which is consistent with other getters in the InteractsWithData trait An example use case is when you're handling GET params in a dashboard.

Old:

$chartType = request()->enum('chart_type', ChartTypeEnum::class) ?: ChartTypeEnum::Bar;

New:

$chartType = request()->enum('chart_type', ChartTypeEnum::class, ChartTypeEnum::Bar);

@shaedrich
Copy link
Contributor

Would be cool to have an attribute on the enum or a method or the like 🤔

@taylorotwell taylorotwell merged commit fc0c66f into laravel:12.x May 14, 2025
59 checks passed
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.