Fixes Factory Using Wrong Model Name#54644
Merged
Merged
Conversation
crynobone
requested changes
Feb 17, 2025
Member
|
@SameOldNick irrelevant code style commit makes it harder to read and review the changes. Please keep the PR to just the required changes. |
SameOldNick
commented
Feb 17, 2025
Contributor
Author
SameOldNick
left a comment
There was a problem hiding this comment.
Removed code styling changes
crynobone
reviewed
Feb 17, 2025
| public static function guessModelNamesUsing(callable $callback) | ||
| { | ||
| static::$modelNameResolver = $callback; | ||
| static::$modelNameResolvers[static::class] = $callback; |
Member
There was a problem hiding this comment.
What would happen if you supply the following to set global model resolver? e.g:
Illuminate\Database\Eloquent\Factories\Factory::guestModelNamesUsing( /* ... */ );
Contributor
Author
There was a problem hiding this comment.
It has no effect. I added a test case showing this: https://github.com/SameOldNick/laravel-framework/commit/ff30fcadb0151d5c75a6236475bb13fa1c0b929d
crynobone
added a commit
that referenced
this pull request
Feb 17, 2025
bug introduced via #54644 Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
taylorotwell
added a commit
that referenced
this pull request
Feb 18, 2025
…)` (#54665) * [11.x] Fix regression bug with global `Factory::guessModelNamesUsing()` bug introduced via #54644 Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> * Update Factory.php --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: Taylor Otwell <taylor@laravel.com>
This was referenced Feb 19, 2025
1 task
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.
This fixes the model name being set for every factory implementation (as explained in #54642)