]> BookStack Code Mirror - bookstack/blob - app/Entities/Repos/DeletionRepo.php
Merge pull request #5917 from BookStackApp/copy_references
[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     public function __construct(
13         protected TrashCan $trashCan
14     ) {
15     }
16
17     public function restore(int $id): int
18     {
19         /** @var Deletion $deletion */
20         $deletion = Deletion::query()->findOrFail($id);
21         Activity::add(ActivityType::RECYCLE_BIN_RESTORE, $deletion);
22
23         return $this->trashCan->restoreFromDeletion($deletion);
24     }
25
26     public function destroy(int $id): int
27     {
28         /** @var Deletion $deletion */
29         $deletion = Deletion::query()->findOrFail($id);
30         Activity::add(ActivityType::RECYCLE_BIN_DESTROY, $deletion);
31
32         return $this->trashCan->destroyFromDeletion($deletion);
33     }
34 }