Skip to content
New issue

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

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

Already on GitHub? # to your account

[11.x] Allow implicit binding to have optional backed enums #51178

Merged
merged 2 commits into from
Apr 22, 2024

Conversation

Neol3108
Copy link
Contributor

I think this PR speaks for itself but this is an example of what wasn't possible before and now is:

<?php

use Illuminate\Support\Facades\Route;

Route::get('/settings/{tab?}', fn (?Tab $tab) => response()->json([
    'tab' => $tab?->value,
]));

enum Tab: string
{
    case Advanced = 'advanced';
    case General = 'general';
}

This doesn't contain breaking changes unless you expect 404s

@Neol3108 Neol3108 changed the title Allow implicit binding to have optional backed enums [11.x] Allow implicit binding to have optional backed enums Apr 22, 2024
@taylorotwell
Copy link
Member

Can we have an actual integration test that defines a route like your example and ensures the proper behavior? Please mark as ready for review when done.

@taylorotwell taylorotwell marked this pull request as draft April 22, 2024 17:58
@Neol3108 Neol3108 force-pushed the optional-backed-enum branch from 24102f2 to 7cb1f54 Compare April 22, 2024 18:49
@Neol3108
Copy link
Contributor Author

@taylorotwell casing was different in the two test files I changed. Stuck to the one used in that file

@Neol3108 Neol3108 marked this pull request as ready for review April 22, 2024 18:57
@taylorotwell taylorotwell merged commit 7042fec into laravel:11.x Apr 22, 2024
28 checks passed
@taylorotwell
Copy link
Member

Thanks

@Neol3108 Neol3108 deleted the optional-backed-enum branch April 23, 2024 06:35
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants