Skip to content

Commit c9d873a

Browse files
committed
path tweak
1 parent dfe34d6 commit c9d873a

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/Commands/MigrateAutoCommand.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Console\Command;
66
use Doctrine\DBAL\Schema\Comparator;
7+
use Illuminate\Support\Arr;
78
use Illuminate\Support\Facades\Schema;
89
use Illuminate\Support\Facades\Artisan;
910
use Illuminate\Database\Schema\Blueprint;
@@ -46,13 +47,22 @@ private function runTraditionalMigrations()
4647

4748
private function runAutomaticMigrations()
4849
{
49-
foreach ((new Finder)->in(config('laravel-automatic-migrations.model_paths')) as $file) {
50-
preg_match('/namespace (.*);/', $file->getContents(), $matches);
50+
$paths = Arr::wrap(config('laravel-automatic-migrations.model_paths'));
51+
$finder = new Finder;
5152

52-
$class = str_replace('.php', '', $matches[1] . '\\' . $file->getFilename());
53+
foreach ($paths as $path) {
54+
if (!is_dir($path)) {
55+
continue;
56+
}
57+
58+
foreach ($finder->in($path) as $file) {
59+
preg_match('/namespace (.*);/', $file->getContents(), $matches);
60+
61+
$class = str_replace('.php', '', $matches[1] . '\\' . $file->getFilename());
5362

54-
if (method_exists($class, 'migration')) {
55-
$this->migrate($class);
63+
if (method_exists($class, 'migration')) {
64+
$this->migrate($class);
65+
}
5666
}
5767
}
5868
}

0 commit comments

Comments
 (0)