]> BookStack Code Mirror - bookstack/blob - app/Entities/Repos/DeletionRepo.php
Updated translator & dependency attribution before release v25.05.1
[bookstack] / app / Entities / Repos / DeletionRepo.php
1 <?php
2
3 namespace BookStack\Entities\Repos;
4
5 use BookStack\Activity\ActivityType;
6 use BookStack\Entities\Models\Deletion;
7 use BookStack\Entities\Tools\TrashCan;
8 use BookStack\Facades\Activity;
9
10 class DeletionRepo
11 {
12     private TrashCan $trashCan;
13
14     public function __construct(TrashCan $trashCan)
15     {
16         $this->trashCan = $trashCan;
17     }
18
19     public function restore(int $id): int
20     {
21         /** @var Deletion $deletion */
22         $deletion = Deletion::query()->findOrFail($id);
23         Activity::add(ActivityType::RECYCLE_BIN_RESTORE, $deletion);
24
25         return $this->trashCan->restoreFromDeletion($deletion);
26     }
27
28     public function destroy(int $id): int
29     {
30         /** @var Deletion $deletion */
31         $deletion = Deletion::query()->findOrFail($id);
32         Activity::add(ActivityType::RECYCLE_BIN_DESTROY, $deletion);
33
34         return $this->trashCan->destroyFromDeletion($deletion);
35     }
36 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.