Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Adds support for PHP's BackedEnum to be "rendered" on blade views. #44445

Merged
merged 5 commits into from
Oct 4, 2022

Conversation

nunomaduro
Copy link
Member

This pull request is a very simple change that allows PHP's BackedEnum to be "rendered" on blade views.

enum UserRoles: string
{
    case ADMIN = 'Admin';
}

// routes/web.php
Route::get('/', function () {
    return view('dashboard', ['role' => UserRoles:: ADMIN]);
});

// dashboard.blade.php
Hello, {{ $role }}.

// ❌ Before: TypeError: htmlspecialchars(): Argument #1 ($string) must be of type string
// ✅ After: Hello, Admin.

Fixes #44431.

@nunomaduro nunomaduro self-assigned this Oct 4, 2022
@nunomaduro nunomaduro marked this pull request as draft October 4, 2022 08:09
@nunomaduro nunomaduro marked this pull request as ready for review October 4, 2022 08:17
@taylorotwell taylorotwell merged commit fcdce7c into 9.x Oct 4, 2022
@taylorotwell taylorotwell deleted the feat/e-enum-value branch October 4, 2022 13:32
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.

Crash when using Blade's echo to render enum
3 participants