Skip to content

Commit

Permalink
feat: add take option
Browse files Browse the repository at this point in the history
  • Loading branch information
gabeta committed Feb 21, 2021
1 parent 9cf7ac2 commit 027f0a1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/Console/LaraPnnCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public function handle()

$skipAsk = $this->option('skip');

$take = $this->option('take');

$this->model = app($argument);

if (! ($this->model instanceof LaraPnnAbstract)) {
Expand All @@ -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 = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Console/LaraPnnMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/Console/LaraPnnRollbackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit 027f0a1

Please sign in to comment.