@@ -39,12 +39,17 @@ public function handle(): int
39
39
$ this ->createResource ($ name );
40
40
$ this ->createTests ($ name );
41
41
42
+ // Create migration
43
+ $ this ->createMigration ($ name );
44
+
45
+ // Add .gitkeep to empty directories
46
+ $ this ->addGitKeepFiles ($ name );
47
+
42
48
$ this ->info ("✅ Domain {$ name } created successfully! " );
43
49
$ this ->newLine ();
44
50
$ this ->info ('Next steps: ' );
45
- $ this ->info ("1. Create migration: php artisan make:migration create_ {$ this ->getTableName ($ name )}_table " );
46
- $ this ->info ('2. Add routes to routes/api.php ' );
47
- $ this ->info ('3. Run tests: php artisan test ' );
51
+ $ this ->info ('1. Add routes to routes/api.php ' );
52
+ $ this ->info ('2. Run tests: php artisan test ' );
48
53
49
54
return self ::SUCCESS ;
50
55
}
@@ -201,6 +206,36 @@ protected function createTests(string $name): void
201
206
$ this ->info ("Created: tests/Feature/ {$ pluralName }Test.php " );
202
207
}
203
208
209
+ protected function createMigration (string $ name ): void
210
+ {
211
+ $ tableName = $ this ->getTableName ($ name );
212
+ $ this ->call ('make:migration ' , [
213
+ 'name ' => "create_ {$ tableName }_table " ,
214
+ '--create ' => $ tableName ,
215
+ ]);
216
+ $ this ->info ("Created migration for table: {$ tableName }" );
217
+ }
218
+
219
+ protected function addGitKeepFiles (string $ name ): void
220
+ {
221
+ $ pluralName = Str::plural ($ name );
222
+ $ directories = [
223
+ app_path ("Domain/ {$ pluralName }" ),
224
+ app_path ("Domain/ {$ pluralName }/Enums " ),
225
+ app_path ("Domain/ {$ pluralName }/Events " ),
226
+ app_path ("Application/Actions/ {$ pluralName }" ),
227
+ app_path ('Infrastructure/API/Requests ' ),
228
+ app_path ('Infrastructure/API/Resources ' ),
229
+ ];
230
+
231
+ foreach ($ directories as $ directory ) {
232
+ if ($ this ->files ->isDirectory ($ directory ) && count ($ this ->files ->files ($ directory )) === 0 ) {
233
+ $ this ->files ->put ("{$ directory }/.gitkeep " , '' );
234
+ $ this ->info ("Added .gitkeep to: {$ directory }" );
235
+ }
236
+ }
237
+ }
238
+
204
239
protected function replacePlaceholders (string $ content , string $ name , array $ extra = []): string
205
240
{
206
241
$ pluralName = Str::plural ($ name );
0 commit comments