Repository navigation
Fix missing UnitEnum support in ModelNotFoundException - #59423
Merged
taylorotwell merged 2 commits intoMar 28, 2026
Merged
Conversation
Extends the enum handling in setModel() to cover UnitEnum as well as BackedEnum. The previous fix (using instanceof BackedEnum) missed UnitEnum cases, which have no ->value but do have a ->name. Using enum_value() — the framework helper — handles both cleanly: - BackedEnum: returns ->value - UnitEnum: returns ->name - Everything else: passes through unchanged Adds tests for both enum types.
* Adjusted previous fix, passing enum_value(...) instead of 'enum_value' to array_map() to fix test results See: laravel#59147
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
jtheuerkauf
marked this pull request as ready for review
March 28, 2026 19:14
sumaiazaman
added a commit
to sumaiazaman/framework
that referenced
this pull request
Mar 30, 2026
Forward-port fix from 12.x (laravel#59423). ModelNotFoundException used instanceof BackedEnum which missed UnitEnum support. Replace with enum_value() helper which handles both BackedEnum and UnitEnum.
3 tasks done
jonagoldman
pushed a commit
to deplox/laravel-framework
that referenced
this pull request
Apr 30, 2026
* fix: use enum_value() in ModelNotFoundException to support UnitEnum Extends the enum handling in setModel() to cover UnitEnum as well as BackedEnum. The previous fix (using instanceof BackedEnum) missed UnitEnum cases, which have no ->value but do have a ->name. Using enum_value() — the framework helper — handles both cleanly: - BackedEnum: returns ->value - UnitEnum: returns ->name - Everything else: passes through unchanged Adds tests for both enum types. * Fix laravel#59147 - enum_value() should be a Closure * Adjusted previous fix, passing enum_value(...) instead of 'enum_value' to array_map() to fix test results See: laravel#59147 --------- Co-authored-by: Isaac Hunja <[email protected]>
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.
Follow up to #55977 (PR #59132 and #59147)
This PR follows up on adding Enum support to the stringification of IDs passed to the exception. Initially only BackedEnum support was added. This switches to
enum_value()to provide full support.The original bug report points out this exception doesn't accept IDs the same way the rest of Builder logic does, particularly for enums. It's a non-breaking change and improves clean query building when dealing with non-stringable data.