-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
Fixes Factory Using Wrong Model Name #54644
Conversation
@SameOldNick irrelevant code style commit makes it harder to read and review the changes. Please keep the PR to just the required changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed code styling changes
@@ -835,7 +835,7 @@ public function modelName() | |||
*/ | |||
public static function guessModelNamesUsing(callable $callback) | |||
{ | |||
static::$modelNameResolver = $callback; | |||
static::$modelNameResolvers[static::class] = $callback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would happen if you supply the following to set global model resolver? e.g:
Illuminate\Database\Eloquent\Factories\Factory::guestModelNamesUsing( /* ... */ );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has no effect. I added a test case showing this: SameOldNick@ff30fca
bug introduced via #54644 Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
…)` (#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 fixes the model name being set for every factory implementation (as explained in #54642)