]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/RecycleBinController.php
Added recycle bin empty notification response with count
[bookstack] / app / Http / Controllers / RecycleBinController.php
1 <?php namespace BookStack\Http\Controllers;
2
3 use BookStack\Entities\Deletion;
4 use BookStack\Entities\Managers\TrashCan;
5 use Illuminate\Http\Request;
6
7 class RecycleBinController extends Controller
8 {
9     /**
10      * Show the top-level listing for the recycle bin.
11      */
12     public function index()
13     {
14         $this->checkPermission('settings-manage');
15         $this->checkPermission('restrictions-manage-all');
16
17         $deletions = Deletion::query()->with(['deletable', 'deleter'])->paginate(10);
18
19         return view('settings.recycle-bin', [
20             'deletions' => $deletions,
21         ]);
22     }
23
24     /**
25      * Empty out the recycle bin.
26      */
27     public function empty()
28     {
29         $this->checkPermission('settings-manage');
30         $this->checkPermission('restrictions-manage-all');
31
32         $deleteCount = (new TrashCan())->destroyFromAllDeletions();
33
34         $this->showSuccessNotification(trans('settings.recycle_bin_empty_notification', ['count' => $deleteCount]));
35         return redirect('/settings/recycle-bin');
36     }
37 }