3 namespace BookStack\Console\Commands;
5 use BookStack\Auth\Permissions\PermissionService;
6 use Illuminate\Console\Command;
8 class RegeneratePermissions extends Command
11 * The name and signature of the console command.
15 protected $signature = 'bookstack:regenerate-permissions {--database= : The database connection to use.}';
18 * The console command description.
22 protected $description = 'Regenerate all system permissions';
25 * The service to handle the permission system.
27 * @var PermissionService
29 protected $permissionService;
32 * Create a new command instance.
34 * @param \BookStack\Auth\\BookStack\Auth\Permissions\PermissionService $permissionService
36 public function __construct(PermissionService $permissionService)
38 $this->permissionService = $permissionService;
39 parent::__construct();
43 * Execute the console command.
47 public function handle()
49 $connection = \DB::getDefaultConnection();
50 if ($this->option('database') !== null) {
51 \DB::setDefaultConnection($this->option('database'));
52 $this->permissionService->setConnection(\DB::connection($this->option('database')));
55 $this->permissionService->buildJointPermissions();
57 \DB::setDefaultConnection($connection);
58 $this->comment('Permissions regenerated');