]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Repos/ChapterRepo.php
Aligned notification capitalisation
[bookstack] / app / Entities / Repos / ChapterRepo.php
index d56874e0d54a9b647ce59f4a84add65fa793f302..b10fc45309d8b6de5e813391687f67364fec8d07 100644 (file)
@@ -1,4 +1,6 @@
-<?php namespace BookStack\Entities\Repos;
+<?php
+
+namespace BookStack\Entities\Repos;
 
 use BookStack\Actions\ActivityType;
 use BookStack\Entities\Models\Book;
@@ -9,11 +11,9 @@ use BookStack\Exceptions\MoveOperationException;
 use BookStack\Exceptions\NotFoundException;
 use BookStack\Facades\Activity;
 use Exception;
-use Illuminate\Support\Collection;
 
 class ChapterRepo
 {
-
     protected $baseRepo;
 
     /**
@@ -26,6 +26,7 @@ class ChapterRepo
 
     /**
      * Get a chapter via the slug.
+     *
      * @throws NotFoundException
      */
     public function getBySlug(string $bookSlug, string $chapterSlug): Chapter
@@ -48,7 +49,8 @@ class ChapterRepo
         $chapter->book_id = $parentBook->id;
         $chapter->priority = (new BookContents($parentBook))->getLastPriority() + 1;
         $this->baseRepo->create($chapter, $input);
-        Activity::addForEntity($chapter, ActivityType::CHAPTER_CREATE);
+        Activity::add(ActivityType::CHAPTER_CREATE, $chapter);
+
         return $chapter;
     }
 
@@ -58,26 +60,29 @@ class ChapterRepo
     public function update(Chapter $chapter, array $input): Chapter
     {
         $this->baseRepo->update($chapter, $input);
-        Activity::addForEntity($chapter, ActivityType::CHAPTER_UPDATE);
+        Activity::add(ActivityType::CHAPTER_UPDATE, $chapter);
+
         return $chapter;
     }
 
     /**
      * Remove a chapter from the system.
+     *
      * @throws Exception
      */
     public function destroy(Chapter $chapter)
     {
         $trashCan = new TrashCan();
         $trashCan->softDestroyChapter($chapter);
-        Activity::addForEntity($chapter, ActivityType::CHAPTER_DELETE);
+        Activity::add(ActivityType::CHAPTER_DELETE, $chapter);
         $trashCan->autoClearOld();
     }
 
     /**
      * Move the given chapter into a new parent book.
      * The $parentIdentifier must be a string of the following format:
-     * 'book:<id>' (book:5)
+     * 'book:<id>' (book:5).
+     *
      * @throws MoveOperationException
      */
     public function move(Chapter $chapter, string $parentIdentifier): Book
@@ -98,7 +103,7 @@ class ChapterRepo
 
         $chapter->changeBook($parent->id);
         $chapter->rebuildPermissions();
-        Activity::addForEntity($chapter, ActivityType::CHAPTER_MOVE);
+        Activity::add(ActivityType::CHAPTER_MOVE, $chapter);
 
         return $parent;
     }