diff --git a/README.md b/README.md index 9144d55..60a6048 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,15 @@ You also have a command that allows you to rollback php artisan larapnn:rollback YouModelNamepace\\YourModel ``` -You can add the skip option to skip the stats part (used if you are using a job): +You can add the take option to take records do you want: + +```shell +php artisan larapnn:migrate YouModelNamepace\\YourModel --take=50000 + +php artisan larapnn:rollback YouModelNamepace\\YourModel --take=50000 +``` + +You can add the skip option to skip the stats part (used if you are using a schedule job): ```shell php artisan larapnn:migrate YouModelNamepace\\YourModel --skip diff --git a/src/Console/LaraPnnCommand.php b/src/Console/LaraPnnCommand.php index c8125de..3226edf 100644 --- a/src/Console/LaraPnnCommand.php +++ b/src/Console/LaraPnnCommand.php @@ -18,6 +18,8 @@ public function handle() $skipAsk = $this->option('skip'); + $take = $this->option('take'); + $this->model = app($argument); if (! ($this->model instanceof LaraPnnAbstract)) { @@ -26,7 +28,11 @@ public function handle() $this->line("\nRetrieval of eligible data in progess. ⌛"); - $queryResults = $this->model->all(); + if ($take) { + $queryResults = $this->model->take($take)->get(); + } else { + $queryResults = $this->model->all(); + } $eligibleModels = []; $eligibleModelsColumns = []; diff --git a/src/Console/LaraPnnMigrateCommand.php b/src/Console/LaraPnnMigrateCommand.php index 513a508..edef772 100644 --- a/src/Console/LaraPnnMigrateCommand.php +++ b/src/Console/LaraPnnMigrateCommand.php @@ -6,7 +6,7 @@ class LaraPnnMigrateCommand extends LaraPnnCommand { - protected $signature = 'larapnn:migrate {model} {--skip}'; + protected $signature = 'larapnn:migrate {model} {--skip} {--take=}'; protected $description = 'Migrate Your tel number for new plan'; diff --git a/src/Console/LaraPnnRollbackCommand.php b/src/Console/LaraPnnRollbackCommand.php index bd47d08..05622bf 100644 --- a/src/Console/LaraPnnRollbackCommand.php +++ b/src/Console/LaraPnnRollbackCommand.php @@ -8,7 +8,7 @@ class LaraPnnRollbackCommand extends LaraPnnCommand { - protected $signature = 'larapnn:rollback {model} {--skip}'; + protected $signature = 'larapnn:rollback {model} {--skip} {--take=}'; protected $description = 'Rollback Your tel number for old plan';