]> BookStack Code Mirror - bookstack/blob - app/Console/Commands/ClearRevisions.php
Updated the swedish lang files
[bookstack] / app / Console / Commands / ClearRevisions.php
1 <?php
2
3 namespace BookStack\Console\Commands;
4
5 use BookStack\Entities\PageRevision;
6 use Illuminate\Console\Command;
7
8 class ClearRevisions 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     protected $pageRevision;
27
28     /**
29      * Create a new command instance.
30      *
31      * @param PageRevision $pageRevision
32      */
33     public function __construct(PageRevision $pageRevision)
34     {
35         $this->pageRevision = $pageRevision;
36         parent::__construct();
37     }
38
39     /**
40      * Execute the console command.
41      *
42      * @return mixed
43      */
44     public function handle()
45     {
46         $deleteTypes = $this->option('all') ? ['version', 'update_draft'] : ['version'];
47         $this->pageRevision->newQuery()->whereIn('type', $deleteTypes)->delete();
48         $this->comment('Revisions deleted');
49     }
50 }