3 namespace BookStack\Console\Commands;
5 use BookStack\Entities\Models\PageRevision;
6 use Illuminate\Console\Command;
8 class ClearRevisions extends Command
11 * The name and signature of the console command.
15 protected $signature = 'bookstack:clear-revisions
16 {--a|all : Include active update drafts in deletion}
20 * The console command description.
24 protected $description = 'Clear page revisions';
26 protected $pageRevision;
29 * Create a new command instance.
31 * @param PageRevision $pageRevision
33 public function __construct(PageRevision $pageRevision)
35 $this->pageRevision = $pageRevision;
36 parent::__construct();
40 * Execute the console command.
44 public function handle()
46 $deleteTypes = $this->option('all') ? ['version', 'update_draft'] : ['version'];
47 $this->pageRevision->newQuery()->whereIn('type', $deleteTypes)->delete();
48 $this->comment('Revisions deleted');