@@ -21,6 +21,7 @@ class CreateModel extends BaseScaffoldCommand
2121 {--a|all : Generate a controller, migration, & seeder for the model}
2222 {--c|controller : Create a new controller for the model}
2323 {--s|seed : Create a new seeder for the model}
24+ {--F|factory : Create a new factory for the model}
2425 {--p|pivot : Indicates if the generated model should be a custom intermediate table model}
2526 {--no-migration : Don \'t create a migration file for the model}
2627 {--uninspiring : Disable inspirational quotes}
@@ -71,6 +72,7 @@ public function handle()
7172 if ($ this ->option ('all ' )) {
7273 $ this ->input ->setOption ('controller ' , true );
7374 $ this ->input ->setOption ('seed ' , true );
75+ $ this ->input ->setOption ('factory ' , true );
7476 }
7577
7678 if ($ this ->option ('controller ' )) {
@@ -84,6 +86,10 @@ public function handle()
8486 if (!$ this ->option ('no-migration ' )) {
8587 $ this ->createMigration ();
8688 }
89+
90+ if ($ this ->option ('factory ' )) {
91+ $ this ->createFactory ();
92+ }
8793 }
8894
8995 /**
@@ -154,4 +160,18 @@ public function createController()
154160 '--uninspiring ' => $ this ->option ('uninspiring ' ),
155161 ]);
156162 }
163+
164+ /**
165+ * Create a factory class for the model.
166+ */
167+ public function createFactory (): void
168+ {
169+ $ this ->call ('create:factory ' , [
170+ 'plugin ' => $ this ->getPluginIdentifier (),
171+ 'factory ' => "{$ this ->getNameInput ()}Factory " ,
172+ '--model ' => $ this ->getNameInput (),
173+ '--force ' => $ this ->option ('force ' ),
174+ '--uninspiring ' => $ this ->option ('uninspiring ' ),
175+ ]);
176+ }
157177}
0 commit comments