]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Repos/BookRepo.php
Guest create page: name field autofocus
[bookstack] / app / Entities / Repos / BookRepo.php
index a692bbaf75a8bf4dca27a62a8b6c133ecc7437de..b5944fd460b2f23737e9c3ddcf22be005e72df4e 100644 (file)
@@ -91,7 +91,8 @@ class BookRepo
     {
         $book = new Book();
         $this->baseRepo->create($book, $input);
-        Activity::addForEntity($book, ActivityType::BOOK_CREATE);
+        $this->baseRepo->updateCoverImage($book, $input['image'] ?? null);
+        Activity::add(ActivityType::BOOK_CREATE, $book);
 
         return $book;
     }
@@ -102,7 +103,12 @@ class BookRepo
     public function update(Book $book, array $input): Book
     {
         $this->baseRepo->update($book, $input);
-        Activity::addForEntity($book, ActivityType::BOOK_UPDATE);
+
+        if (array_key_exists('image', $input)) {
+            $this->baseRepo->updateCoverImage($book, $input['image'], $input['image'] === null);
+        }
+
+        Activity::add(ActivityType::BOOK_UPDATE, $book);
 
         return $book;
     }
@@ -127,7 +133,7 @@ class BookRepo
     {
         $trashCan = new TrashCan();
         $trashCan->softDestroyBook($book);
-        Activity::addForEntity($book, ActivityType::BOOK_DELETE);
+        Activity::add(ActivityType::BOOK_DELETE, $book);
 
         $trashCan->autoClearOld();
     }