3 namespace BookStack\Console\Commands;
5 use BookStack\Permissions\JointPermissionBuilder;
6 use Illuminate\Console\Command;
7 use Illuminate\Support\Facades\DB;
9 class RegeneratePermissionsCommand extends Command
12 * The name and signature of the console command.
16 protected $signature = 'bookstack:regenerate-permissions
17 {--database= : The database connection to use}';
20 * The console command description.
24 protected $description = 'Regenerate all system permissions';
27 * Execute the console command.
29 public function handle(JointPermissionBuilder $permissionBuilder): int
31 $connection = DB::getDefaultConnection();
33 if ($this->option('database')) {
34 DB::setDefaultConnection($this->option('database'));
37 $permissionBuilder->rebuildForAll();
39 DB::setDefaultConnection($connection);
40 $this->comment('Permissions regenerated');