Skip to content

Fix factory creation through attributes #55190

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

Merged
merged 1 commit into from
Mar 27, 2025

Conversation

davidstoker
Copy link
Contributor

Problem

The UseFactory attribute introduced in #54065 instantiates the factory class using new instead of calling the new() static method. The new() static method will call the configure() method where factory callbacks may exist. Factories that have callbacks fail to work correctly if using UseFactory.

Solution

Call new() to be consistent with newFactory() method and documentation's guidance.

@taylorotwell taylorotwell merged commit aa1128c into laravel:12.x Mar 27, 2025
41 checks passed
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.

2 participants