Skip to content
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

Merged
merged 8 commits into from
Feb 17, 2025
Merged

Conversation

SameOldNick
Copy link
Contributor

This fixes the model name being set for every factory implementation (as explained in #54642)

@crynobone
Copy link
Member

@SameOldNick irrelevant code style commit makes it harder to read and review the changes. Please keep the PR to just the required changes.

Copy link
Contributor Author

@SameOldNick SameOldNick left a 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;
Copy link
Member

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( /* ... */ );

Copy link
Contributor Author

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

@taylorotwell taylorotwell merged commit 415a539 into laravel:11.x Feb 17, 2025
43 of 44 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants