Skip to content

Commit 046677b

Browse files
author
Andrey Helldar
committed
Fix for previous versions of Laravel
1 parent b010930 commit 046677b

File tree

5 files changed

+45
-17
lines changed

5 files changed

+45
-17
lines changed

src/Facades/Version.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Helldar\LaravelActions\Facades;
4+
5+
use Helldar\LaravelActions\Helpers\Version as Helper;
6+
use Illuminate\Support\Facades\Facade;
7+
8+
/**
9+
* @method static bool is6x()
10+
*/
11+
class Version extends Facade
12+
{
13+
protected static function getFacadeAccessor()
14+
{
15+
return Helper::class;
16+
}
17+
}

src/Helpers/Version.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Helldar\LaravelActions\Helpers;
4+
5+
use Illuminate\Foundation\Application;
6+
use Illuminate\Support\Str;
7+
8+
class Version
9+
{
10+
public function is6x(): bool
11+
{
12+
return $this->major() === 6;
13+
}
14+
15+
protected function major(): int
16+
{
17+
return Str::before(Application::VERSION, '.');
18+
}
19+
}

src/Support/Migrator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ protected function runUp($file, $batch, $pretend)
7878
*/
7979
protected function runDown($file, $migration, $pretend)
8080
{
81-
$instance = $this->resolvePath($file);
82-
83-
$name = $this->getMigrationName($file);
81+
$instance = $this->resolve(
82+
$name = $this->getMigrationName($file)
83+
);
8484

8585
if (! $this->allowEnvironment($instance)) {
86-
$this->note("<info>Roll back:</info> {$name} was skipped on this environment");
86+
$this->note("<info>Rolling back:</info> {$name} was skipped on this environment");
8787

8888
return;
8989
}

tests/Commands/StatusTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ public function testStatusCommand()
1515
$this->assertDatabaseHasTable($this->table);
1616
$this->assertDatabaseCount($this->table, 0);
1717

18-
if ($this->is6x()) {
19-
$this->artisan('migrate:actions:status')->run();
20-
} else {
21-
$this->artisan('migrate:actions:status')->expectsTable([], [])->run();
22-
}
18+
$this->is6x()
19+
? $this->artisan('migrate:actions:status')->run()
20+
: $this->artisan('migrate:actions:status')->expectsTable([], [])->run();
2321

2422
$this->artisan('make:migration:action', ['name' => 'Status'])->run();
2523
$this->artisan('migrate:actions')->run();

tests/Concerns/Laraveable.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22

33
namespace Tests\Concerns;
44

5-
use Illuminate\Foundation\Application;
6-
use Illuminate\Support\Str;
5+
use Helldar\LaravelActions\Facades\Version;
76

87
trait Laraveable
98
{
109
protected function is6x(): bool
1110
{
12-
return $this->majorVersion() === 6;
13-
}
14-
15-
protected function majorVersion(): int
16-
{
17-
return Str::before(Application::VERSION, '.');
11+
return Version::is6x();
1812
}
1913
}

0 commit comments

Comments
 (0)