]> BookStack Code Mirror - bookstack/blob - app/Console/Commands/ClearRevisionsCommand.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Console / Commands / ClearRevisionsCommand.php
1 <?php
2
3 namespace BookStack\Console\Commands;
4
5 use BookStack\Entities\Models\PageRevision;
6 use Illuminate\Console\Command;
7
8 class ClearRevisionsCommand extends Command
9 {
10     /**
11      * The name and signature of the console command.
12      *
13      * @var string
14      */
15     protected $signature = 'bookstack:clear-revisions
16                             {--a|all : Include active update drafts in deletion}
17                             ';
18
19     /**
20      * The console command description.
21      *
22      * @var string
23      */
24     protected $description = 'Clear page revisions';
25
26     /**
27      * Execute the console command.
28      */
29     public function handle(): int
30     {
31         $deleteTypes = $this->option('all') ? ['version', 'update_draft'] : ['version'];
32         PageRevision::query()->whereIn('type', $deleteTypes)->delete();
33         $this->comment('Revisions deleted');
34         return 0;
35     }
36 }