Repository navigation
[13.x] Allow enums in environment checks - #61730
Merged
Merged
Conversation
App::environment() threw when given an enum, and scheduled events limited to enum environments silently never ran. Normalize the values with enum_value(), as the #[Bind] attribute already does.
Taldres
marked this pull request as draft
September 25, 2026 12:29
Taldres
marked this pull request as ready for review
September 25, 2026 12:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Apps that model their environments as an enum can already use it with the
#[Bind]attribute, but not with the framework's other environment checks:The scheduler case is the more surprising one.
environments()stores the enum as-is, andrunsInEnvironment()compares it against the current environment string, so the task is silently skipped on every environment.This PR passes the given values through
enum_value(), the same way#[Bind]already handles itsenvironmentsargument. Backed enums (and unit enums, by case name) now work with:App::environment()/app()->environment(), including@env(...)in Blade, which compiles down to itenvironments()on scheduled events and onSchedule::environments(...)->group(...)String values behave exactly as before, wildcard patterns included, and signatures and return types are unchanged. The scheduler stores the normalized strings, so anything reading
$event->environments, likeschedule:list --json, still gets plain strings.Tests cover both the application and the scheduler.