searchIndex = $searchIndex; } /** * Execute the console command. * * @return mixed */ public function handle() { $connection = DB::getDefaultConnection(); if ($this->option('database') !== null) { DB::setDefaultConnection($this->option('database')); } $this->searchIndex->indexAllEntities(function (Entity $model, int $processed, int $total): void { $this->info('Indexed ' . class_basename($model) . ' entries (' . $processed . '/' . $total . ')'); }); DB::setDefaultConnection($connection); $this->line('Search index regenerated!'); return static::SUCCESS; } }