Skip to content

Commit 8a130ce

Browse files
author
Andrey Helldar
authored
Merge pull request #54 from TheDragonCode/2.x
Fixed path detection in Rollback, Refresh and Status commands
2 parents 42b84c8 + 981bbf0 commit 8a130ce

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

src/Concerns/Database.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,13 @@ protected function getMigrationPath(): string
99
{
1010
return $this->laravel->databasePath('actions');
1111
}
12+
13+
protected function getMigrationPaths(): array
14+
{
15+
if ($paths = $this->optionPath()) {
16+
return $paths;
17+
}
18+
19+
return [$this->getMigrationPath()];
20+
}
1221
}

src/Concerns/Optionable.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ protected function optionStep(?int $default = null): ?int
1919

2020
protected function optionPath(): ?array
2121
{
22+
if (! $this->hasOption('path')) {
23+
return null;
24+
}
25+
2226
if ($path = $this->option('path')) {
2327
return collect($path)->map(function ($path) {
2428
if ($this->usingRealPath()) {

src/Console/Migrate.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,10 @@ public function handle()
6262
protected function prepareDatabase(): void
6363
{
6464
if (! $this->migrator->repositoryExists()) {
65-
$this->call(Names::INSTALL, array_filter([
66-
'--database' => $this->optionDatabase(),
67-
]));
65+
$this->call(Names::INSTALL,
66+
array_filter([
67+
'--database' => $this->optionDatabase(),
68+
]));
6869
}
6970
}
70-
71-
protected function getMigrationPaths(): array
72-
{
73-
if ($paths = $this->optionPath()) {
74-
return $paths;
75-
}
76-
77-
return [$this->getMigrationPath()];
78-
}
7971
}

src/Console/Status.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
use DragonCode\LaravelActions\Concerns\Database;
66
use DragonCode\LaravelActions\Concerns\Infoable;
7+
use DragonCode\LaravelActions\Concerns\Optionable;
78
use DragonCode\LaravelActions\Constants\Names;
89
use Illuminate\Database\Console\Migrations\StatusCommand as BaseCommand;
910

1011
class Status extends BaseCommand
1112
{
1213
use Database;
1314
use Infoable;
15+
use Optionable;
1416

1517
/**
1618
* The console command name.

0 commit comments

Comments
 (0)