4 namespace BookStack\Entities\Repos;
6 use BookStack\Entities\Book;
7 use BookStack\Exceptions\NotFoundException;
8 use BookStack\Exceptions\NotifyException;
10 class BookRepo extends EntityRepo
14 * Fetch a book by its slug.
17 * @throws NotFoundException
19 public function getBySlug(string $slug): Book
21 /** @var Book $book */
22 $book = $this->getEntityBySlug('book', $slug);
27 * Destroy the provided book and all its child entities.
29 * @throws NotifyException
32 public function destroyBook(Book $book)
34 foreach ($book->pages as $page) {
35 $this->destroyPage($page);
38 foreach ($book->chapters as $chapter) {
39 $this->destroyChapter($chapter);
42 $this->destroyEntityCommonRelations($book);