Skip to content

Commit

Permalink
Fix issues with indexing soft delete indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljennings committed Feb 25, 2020
1 parent 5700a9d commit 93ce479
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Commands/ReIndexLaralastica.php
Expand Up @@ -89,10 +89,16 @@ protected function index($key, Model $model, $chunks)
{
$this->info("\n\nRe-indexing " . $key . "\n");

$total = $model->count();
if (in_array(SearchSoftDeletes::class, class_uses($model))) {
$query = $model->withTrashed();
} else {
$query = $model->newQuery();
}

$total = $query->count();
$bar = $this->output->createProgressBar($total);

$model->with($this->with($key))->chunk($chunks, function($models) use ($model, $bar) {
$query->with($this->with($key))->chunk($chunks, function($models) use ($model, $bar) {
$this->dispatcher->dispatch(new IndexModels($models, $model->getIndex()));

$bar->advance($models->count());
Expand Down

0 comments on commit 93ce479

Please sign in to comment.