Skip to content

Commit fbaf5b0

Browse files
Add Domain Model migration
1 parent a146dcc commit fbaf5b0

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

src/Commands/MakeDomainCommand.php

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ public function handle(): int
3939
$this->createResource($name);
4040
$this->createTests($name);
4141

42+
// Create migration
43+
$this->createMigration($name);
44+
45+
// Add .gitkeep to empty directories
46+
$this->addGitKeepFiles($name);
47+
4248
$this->info("✅ Domain {$name} created successfully!");
4349
$this->newLine();
4450
$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');
4853

4954
return self::SUCCESS;
5055
}
@@ -201,6 +206,36 @@ protected function createTests(string $name): void
201206
$this->info("Created: tests/Feature/{$pluralName}Test.php");
202207
}
203208

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+
204239
protected function replacePlaceholders(string $content, string $name, array $extra = []): string
205240
{
206241
$pluralName = Str::plural($name);

0 commit comments

Comments
 (0)