Skip to content

Commit 6aae7b1

Browse files
authored
Merge pull request #352 from billypoke/model-path-config
Allow the status command with no model given to read from config
2 parents 1ce3fe7 + 4d53fa1 commit 6aae7b1

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ composer.lock
55
.DS_Store
66
Thumbs.db
77
.idea
8+
.phpunit.result.cache

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,15 @@ Or you can pass a searchable model argument:
148148

149149
`php artisan scout:status "App\Models\Post"`
150150

151+
If your models are not in the default location `app` or one of its subdirectories, you may set the `modelPath` option
152+
```php
153+
// config/scout.php
154+
'tntsearch' => [
155+
// ...
156+
'modelPath' => 'models',
157+
],
158+
```
159+
151160
![Image of Scout Status Command](https://teamtnt.github.io/img/scout_status_single_new.png)
152161

153162
## Constraints

src/Console/StatusCommand.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
use Illuminate\Console\Command;
66
use Illuminate\Contracts\Events\Dispatcher;
7+
use Symfony\Component\Finder\Finder;
78
use TeamTNT\TNTSearch\Exceptions\IndexNotFoundException;
8-
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
99
use TeamTNT\TNTSearch\TNTSearch;
10-
use Illuminate\Support\Facades\Schema;
11-
use Symfony\Component\Finder\Finder;
1210

1311
class StatusCommand extends Command
1412
{
@@ -89,7 +87,9 @@ private function getProjectClasses(): array
8987
{
9088

9189
if (self::$declaredClasses === null) {
92-
$configFiles = Finder::create()->files()->name('*.php')->notName('*.blade.php')->in(app()->path());
90+
$configFiles = Finder::create()->files()
91+
->name('*.php')->notName('*.blade.php')
92+
->in(config('scout.tntsearch.modelPath', app()->path()));
9393

9494
foreach ($configFiles->files() as $file) {
9595
try {

0 commit comments

Comments
 (0)