Skip to content

Commit

Permalink
Update MakeCrudModuleCommand.php
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Jan 23, 2025
1 parent 2d4eb73 commit d8eebdc
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Commands/Modules/MakeCrudModuleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,22 @@ protected function makeModel(string $name): void
*/
protected function makeMigration(string $name): void
{
$migrationPath = config('laravel-crod.modules.migration_path', 'Database\Migrations');
$path = "$this->module_namespace\\$name\\$migrationPath";
if (!File::isDirectory(base_path($path))) {
File::makeDirectory(base_path($path), 0755, true);
$migrationPath = config('laravel-crod.modules.migration_path', 'Database/Migrations');
$relativePath = "Modules/$name/$migrationPath";
$fullPath = base_path($relativePath);

// Ensure the directory exists
if (!File::isDirectory($fullPath)) {
File::makeDirectory($fullPath, 0755, true);
}

// Generate the migration name
$currentNameWithCheckLatestLetter = LaravelCrodServiceFacade::getCurrentNameWithCheckLatestLetter($name);

// Call the make:migration Artisan command
$this->call('make:migration', [
'name' => 'create_'.$currentNameWithCheckLatestLetter.'_table',
'--path' => $path,
'name' => 'create_' . $currentNameWithCheckLatestLetter . '_table',
'--path' => $relativePath,
'--create' => true,
]);
}
Expand Down

0 comments on commit d8eebdc

Please sign in to comment.