diff --git a/src/Console/LaraPnnCommand.php b/src/Console/LaraPnnCommand.php index c810aec..edf8d26 100644 --- a/src/Console/LaraPnnCommand.php +++ b/src/Console/LaraPnnCommand.php @@ -16,12 +16,16 @@ public function handle() { $argument = $this->argument('model'); + $skipAsk = $this->option('skip'); + $this->model = app($argument); if (! ($this->model instanceof LaraPnnAbstract)) { throw new \InvalidArgumentException($argument.' must implement '.LaraPnnAbstract::class); } + $this->line("\nRetrieval of eligible data in progess. ⌛"); + $queryResults = $this->model->all(); $eligibleModels = []; @@ -42,7 +46,7 @@ public function handle() $this->line("\n {$this->description} | Stats for {$this->model->getTable()} table: \n"); $this->line("Eligible row: {$eligibleModelsLength}"); - $this->line("Eligible tel number column: {$eligibleModelsColumnsLength}"); + $this->line("Eligible tel number column: {$eligibleModelsColumnsLength}\n"); if (!$eligibleModels) { @@ -51,22 +55,26 @@ public function handle() return false; } - $migrate = $this->ask('You do want to continues ? [yes|no]', 'yes'); - - if ($migrate === 'yes') { - $start = microtime(true); + $start = microtime(true); + if ($skipAsk) { $this->migrate($eligibleModels, $eligibleModelsColumns); + } else { + $migrate = $this->ask('You do want to continues ? [yes|no]', 'yes'); - $time = number_format(microtime(true) - $start, 3); - - $this->line("Execution time {$time} seconds\n"); + if ($migrate === 'yes') { + $this->migrate($eligibleModels, $eligibleModelsColumns); + } } + + $time = number_format(microtime(true) - $start, 3); + + $this->line("Execution time {$time} seconds\n"); } private function migrate($models, $columns) { - $this->line("Action in progress, please wait ! \n"); + $this->line("Action in progress, please wait ! ✋\n"); foreach ($columns as $column => $modelIds) { $this->migrateByEligibleColumn($models, $column, $modelIds); diff --git a/src/Console/LaraPnnMigrateCommand.php b/src/Console/LaraPnnMigrateCommand.php index 6f6624c..513a508 100644 --- a/src/Console/LaraPnnMigrateCommand.php +++ b/src/Console/LaraPnnMigrateCommand.php @@ -6,7 +6,7 @@ class LaraPnnMigrateCommand extends LaraPnnCommand { - protected $signature = 'larapnn:migrate {model}'; + protected $signature = 'larapnn:migrate {model} {--skip}'; protected $description = 'Migrate Your tel number for new plan'; diff --git a/src/Console/LaraPnnRollbackCommand.php b/src/Console/LaraPnnRollbackCommand.php index ca97453..bd47d08 100644 --- a/src/Console/LaraPnnRollbackCommand.php +++ b/src/Console/LaraPnnRollbackCommand.php @@ -8,9 +8,9 @@ class LaraPnnRollbackCommand extends LaraPnnCommand { - protected $signature = 'larapnn:rollback {model}'; + protected $signature = 'larapnn:rollback {model} {--skip}'; - protected $description = 'Rollback Your tel number for last plan'; + protected $description = 'Rollback Your tel number for old plan'; protected function getEligibleFields($result) {