X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ddb7f33868ea499ab8f48a7062f145e8c0fbe02f..refs/pull/2393/head:/app/Entities/Repos/ChapterRepo.php diff --git a/app/Entities/Repos/ChapterRepo.php b/app/Entities/Repos/ChapterRepo.php index c6f3a2d2f..281cc2cab 100644 --- a/app/Entities/Repos/ChapterRepo.php +++ b/app/Entities/Repos/ChapterRepo.php @@ -1,15 +1,14 @@ book_id = $parentBook->id; $chapter->priority = (new BookContents($parentBook))->getLastPriority() + 1; $this->baseRepo->create($chapter, $input); + Activity::addForEntity($chapter, ActivityType::CHAPTER_CREATE); return $chapter; } @@ -59,6 +58,7 @@ class ChapterRepo public function update(Chapter $chapter, array $input): Chapter { $this->baseRepo->update($chapter, $input); + Activity::addForEntity($chapter, ActivityType::CHAPTER_UPDATE); return $chapter; } @@ -77,7 +77,9 @@ class ChapterRepo public function destroy(Chapter $chapter) { $trashCan = new TrashCan(); - $trashCan->destroyChapter($chapter); + $trashCan->softDestroyChapter($chapter); + Activity::addForEntity($chapter, ActivityType::CHAPTER_DELETE); + $trashCan->autoClearOld(); } /** @@ -96,6 +98,7 @@ class ChapterRepo throw new MoveOperationException('Chapters can only be moved into books'); } + /** @var Book $parent */ $parent = Book::visible()->where('id', '=', $entityId)->first(); if ($parent === null) { throw new MoveOperationException('Book to move chapter into not found'); @@ -103,6 +106,8 @@ class ChapterRepo $chapter->changeBook($parent->id); $chapter->rebuildPermissions(); + Activity::addForEntity($chapter, ActivityType::CHAPTER_MOVE); + return $parent; } }