Files
tbbank-new/app/Modules/Core/Commands/ModuleMakeMigration.php
2025-10-22 20:08:22 +05:00

49 lines
1.2 KiB
PHP

<?php
namespace App\Modules\Core\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
class ModuleMakeMigration extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'module:migration {module} {migration}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a new migration file for a module';
/**
* Execute the console command.
*/
public function handle(): void
{
$moduleName = $this->argument('module');
$migrationName = $this->argument('migration');
$modulePath = modules_path($moduleName);
if (! is_dir($modulePath)) {
$this->error("Module [{$moduleName}] does not exist.");
return;
}
$migrationPath = "app/Modules/{$moduleName}/Database/Migrations";
Artisan::call('make:migration', [
'name' => $migrationName,
'--path' => $migrationPath,
]);
$this->info("Migration [{$migrationName}] created successfully in module [{$moduleName}].");
}
}