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

[11.x] Add HasFactory trait to make:model generation command using --all options #53391

Merged
merged 6 commits into from
Nov 5, 2024

Conversation

adel007gh
Copy link
Contributor

Description

This pull request enhances the make:model Artisan command by ensuring that models generated with the --all option automatically include the HasFactory trait. This addition streamlines the process for developers by providing a ready-to-use factory for database testing and seeding.

Benefits to End Users

  • Simplifies model creation by automatically incorporating the HasFactory trait, which is essential for database testing.
  • Reduces boilerplate code for developers, allowing for quicker development cycles.
  • Maintains backward compatibility with existing features of Laravel, ensuring no breaking changes.

Testing

I have added a feature test that verifies the Post model file is created with the HasFactory trait included. The test has been executed successfully and all assertions passed.

Documentation

The relevant documentation in the make:model command section should be updated to reflect this new behavior. I will make sure to provide the necessary updates in the documentation as part of this pull request.

@taylorotwell
Copy link
Member

Tests fail.

@taylorotwell taylorotwell marked this pull request as draft November 3, 2024 20:56
@crynobone crynobone changed the title Add HasFactory trait to Post model generation command [11.x] Add HasFactory trait to make:model generation command using --all` options Nov 4, 2024
@crynobone crynobone marked this pull request as ready for review November 4, 2024 01:52
@crynobone
Copy link
Member

Fixed tests

@crynobone crynobone changed the title [11.x] Add HasFactory trait to make:model generation command using --all` options [11.x] Add HasFactory trait to make:model generation command using --all options Nov 4, 2024
@adel007gh
Copy link
Contributor Author

Thanks @crynobone for fixing this and ensuring the tests pass

@OhmygoodR
Copy link

OhmygoodR commented Nov 4, 2024

hi Adel and Crynobone
it works, thank you so much for your help!

@taylorotwell taylorotwell merged commit 488b367 into laravel:11.x Nov 5, 2024
31 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.

HasFactory didn't include in Model when use the command make:model --all or -a
4 participants