3 namespace BookStack\Console\Commands;
5 use BookStack\References\ReferenceStore;
6 use Illuminate\Console\Command;
7 use Illuminate\Support\Facades\DB;
9 class RegenerateReferencesCommand extends Command
12 * The name and signature of the console command.
16 protected $signature = 'bookstack:regenerate-references
17 {--database= : The database connection to use}';
20 * The console command description.
24 protected $description = 'Regenerate all the cross-item model reference index';
27 * Execute the console command.
29 public function handle(ReferenceStore $references): int
31 $connection = DB::getDefaultConnection();
33 if ($this->option('database')) {
34 DB::setDefaultConnection($this->option('database'));
37 $references->updateForAll();
39 DB::setDefaultConnection($connection);
41 $this->comment('References have been regenerated');