Skip to content

Commit dde2d87

Browse files
author
Jordan Hoff
committed
Add recursive option to config
1 parent e9fef7f commit dde2d87

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

config/config.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@
44

55
/*
66
* All models in these directories will be scanned for ER diagram generation.
7-
* The directories will not be scanned recursively, so be sure to add all
8-
* directories that contain your models.
7+
* By default, the `app` directory will be scanned recursively for models.
98
*/
109
'directories' => [
11-
// app_path('models'),
10+
app_path(),
1211
],
1312

13+
/*
14+
* If true, all directories specified will be scanned recursively for models.
15+
* Set this to false if you prefer to explicitly define each directory that should
16+
* be scanned for models.
17+
*/
18+
'recursive' => true,
19+
1420
/*
1521
* The generator will automatically try to look up the model specific columns
1622
* and add them to the generated output. If you do not wish to use this
@@ -92,4 +98,4 @@
9298
],
9399
]
94100

95-
];
101+
];

src/GenerateDiagramCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ protected function getModelsThatShouldBeInspected(): Collection
8282
{
8383
$directories = config('erd-generator.directories');
8484

85-
$modelsFromDirectories = empty($directories) ?
86-
$this->modelFinder->getModelsInDirectory(app_path(), true) :
87-
$this->getAllModelsFromEachDirectory($directories);
85+
$modelsFromDirectories = $this->getAllModelsFromEachDirectory($directories);
8886

8987
return $modelsFromDirectories;
9088
}

src/ModelFinder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ public function __construct(Filesystem $filesystem)
2222
$this->filesystem = $filesystem;
2323
}
2424

25-
public function getModelsInDirectory(string $directory, bool $recursive = false): Collection
25+
public function getModelsInDirectory(string $directory): Collection
2626
{
27-
$files = $recursive ?
27+
$files = config('erd-generator.recursive') ?
2828
$this->filesystem->allFiles($directory) :
2929
$this->filesystem->files($directory);
3030

0 commit comments

Comments
 (0)