Skip to content

Fixes Factory Using Wrong Model Name#54644

Merged
taylorotwell merged 8 commits into
laravel:11.xfrom
SameOldNick:11.x
Feb 17, 2025
Merged

Fixes Factory Using Wrong Model Name#54644
taylorotwell merged 8 commits into
laravel:11.xfrom
SameOldNick:11.x

Conversation

@SameOldNick
Copy link
Copy Markdown
Contributor

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

Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
Comment thread src/Illuminate/Database/Eloquent/Factories/Factory.php Outdated
@crynobone
Copy link
Copy Markdown
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
Copy Markdown
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

public static function guessModelNamesUsing(callable $callback)
{
static::$modelNameResolver = $callback;
static::$modelNameResolvers[static::class] = $callback;
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taylorotwell taylorotwell merged commit 415a539 into laravel:11.x Feb 17, 2025
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