Skip to content

Commit

Permalink
Merge pull request #352 from billypoke/model-path-config
Browse files Browse the repository at this point in the history
Allow the status command with no model given to read from config
  • Loading branch information
nticaric committed Mar 6, 2023
2 parents 1ce3fe7 + 4d53fa1 commit 6aae7b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ composer.lock
.DS_Store
Thumbs.db
.idea
.phpunit.result.cache
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ Or you can pass a searchable model argument:

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

If your models are not in the default location `app` or one of its subdirectories, you may set the `modelPath` option
```php
// config/scout.php
'tntsearch' => [
// ...
'modelPath' => 'models',
],
```

![Image of Scout Status Command](https://teamtnt.github.io/img/scout_status_single_new.png)

## Constraints
Expand Down
8 changes: 4 additions & 4 deletions src/Console/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

use Illuminate\Console\Command;
use Illuminate\Contracts\Events\Dispatcher;
use Symfony\Component\Finder\Finder;
use TeamTNT\TNTSearch\Exceptions\IndexNotFoundException;
use TeamTNT\TNTSearch\Indexer\TNTIndexer;
use TeamTNT\TNTSearch\TNTSearch;
use Illuminate\Support\Facades\Schema;
use Symfony\Component\Finder\Finder;

class StatusCommand extends Command
{
Expand Down Expand Up @@ -89,7 +87,9 @@ private function getProjectClasses(): array
{

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

foreach ($configFiles->files() as $file) {
try {
Expand Down

0 comments on commit 6aae7b1

Please sign in to comment.