3 namespace BookStack\Console\Commands;
5 use BookStack\References\ReferenceStore;
6 use Illuminate\Console\Command;
7 use Illuminate\Support\Facades\DB;
9 class RegenerateReferences extends Command
12 * The name and signature of the console command.
16 protected $signature = 'bookstack:regenerate-references {--database= : The database connection to use.}';
19 * The console command description.
23 protected $description = 'Regenerate all the cross-item model reference index';
25 protected ReferenceStore $references;
28 * Create a new command instance.
32 public function __construct(ReferenceStore $references)
34 $this->references = $references;
35 parent::__construct();
39 * Execute the console command.
43 public function handle()
45 $connection = DB::getDefaultConnection();
47 if ($this->option('database')) {
48 DB::setDefaultConnection($this->option('database'));
51 $this->references->updateForAllPages();
53 DB::setDefaultConnection($connection);
55 $this->comment('References have been regenerated');