install
This commit is contained in:
48
app/Modules/Core/Commands/ModuleMakeMigration.php
Normal file
48
app/Modules/Core/Commands/ModuleMakeMigration.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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}].");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user