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 public function __construct(PermissionService $permissionService)
36 $this->permissionService = $permissionService;
37 parent::__construct();
41 * Execute the console command.
45 public function handle()
47 $connection = \DB::getDefaultConnection();
48 if ($this->option('database') !== null) {
49 \DB::setDefaultConnection($this->option('database'));
50 $this->permissionService->setConnection(\DB::connection($this->option('database')));
53 $this->permissionService->buildJointPermissions();
55 \DB::setDefaultConnection($connection);
56 $this->comment('Permissions regenerated');