Skip to content

Commit 592c68e

Browse files
author
Andrey Helldar
committed
Laravel 6 compatibility
1 parent e8f91ee commit 592c68e

File tree

7 files changed

+59
-35
lines changed

7 files changed

+59
-35
lines changed
File renamed without changes.

resources/stub/migration.stub

Lines changed: 0 additions & 16 deletions
This file was deleted.

resources/stub/migration.update.stub

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Console/Refresh.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function handle()
4949
'--force' => true,
5050
]));
5151

52-
if ($this->laravel->bound(Dispatcher::class)) {
52+
if ($this->laravel->bound(Dispatcher::class) && class_exists(DatabaseRefreshed::class)) {
5353
$this->laravel[Dispatcher::class]->dispatch(
5454
new DatabaseRefreshed()
5555
);

src/ServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
use Helldar\LaravelActions\Console\Status;
1212
use Helldar\LaravelActions\Constants\Action;
1313
use Helldar\LaravelActions\Constants\Command;
14+
use Helldar\LaravelActions\Support\MigrationCreator;
15+
use Helldar\LaravelActions\Support\Migrator;
1416
use Illuminate\Contracts\Events\Dispatcher;
1517
use Illuminate\Database\Migrations\DatabaseMigrationRepository;
16-
use Illuminate\Database\Migrations\MigrationCreator;
17-
use Illuminate\Database\Migrations\Migrator;
1818
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
1919

2020
final class ServiceProvider extends BaseServiceProvider

src/Support/MigrationCreator.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace Helldar\LaravelActions\Support;
4+
5+
use Illuminate\Database\Migrations\MigrationCreator as BaseMigrationCreator;
6+
use Illuminate\Filesystem\Filesystem;
7+
8+
final class MigrationCreator extends BaseMigrationCreator
9+
{
10+
protected $customStubPath;
11+
12+
public function __construct(Filesystem $files, ?string $custom_stub_path)
13+
{
14+
parent::__construct($files, $custom_stub_path);
15+
16+
$this->customStubPath = $custom_stub_path;
17+
}
18+
19+
public function create($name, $path, $table = null, $create = false)
20+
{
21+
$this->files->ensureDirectoryExists($path);
22+
23+
return parent::create($name, $path, $table, $create);
24+
}
25+
26+
public function stubPath()
27+
{
28+
return realpath($this->customStubPath);
29+
}
30+
31+
protected function getStub($table, $create)
32+
{
33+
$stub = $this->stubPath() . '/action.stub';
34+
35+
return $this->files->get($stub);
36+
}
37+
}

src/Support/Migrator.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\Support;
4+
5+
use Illuminate\Database\Migrations\Migrator as BaseMigrator;
6+
7+
final class Migrator extends BaseMigrator
8+
{
9+
public function usingConnection($name, callable $callback)
10+
{
11+
$prev = $this->resolver->getDefaultConnection();
12+
13+
$this->setConnection($name);
14+
15+
return tap($callback(), function () use ($prev) {
16+
$this->setConnection($prev);
17+
});
18+
}
19+
}

0 commit comments

Comments
 (0)