diff --git a/app/Entities/Chapter.php b/app/Entities/Chapter.php index 3290afcfa..5f5509efa 100644 --- a/app/Entities/Chapter.php +++ b/app/Entities/Chapter.php @@ -5,7 +5,6 @@ use Illuminate\Support\Collection; /** * Class Chapter * @property Collection $pages - * @package BookStack\Entities */ class Chapter extends BookChild { @@ -52,15 +51,6 @@ class Chapter extends BookChild return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description; } - /** - * Check if this chapter has any child pages. - * @return bool - */ - public function hasChildren() - { - return count($this->pages) > 0; - } - /** * Get the visible pages in this chapter. */ diff --git a/app/Entities/Managers/BookContents.php b/app/Entities/Managers/BookContents.php index 52447e43b..b9844da57 100644 --- a/app/Entities/Managers/BookContents.php +++ b/app/Entities/Managers/BookContents.php @@ -53,12 +53,16 @@ class BookContents $pages->groupBy('chapter_id')->each(function ($pages, $chapter_id) use ($chapterMap, &$lonePages) { $chapter = $chapterMap->get($chapter_id); if ($chapter) { - $chapter->setAttribute('pages', collect($pages)->sortBy($this->bookChildSortFunc())); + $chapter->setAttribute('visible_pages', collect($pages)->sortBy($this->bookChildSortFunc())); } else { $lonePages = $lonePages->concat($pages); } }); + $chapters->whereNull('visible_pages')->each(function (Chapter $chapter) { + $chapter->setAttribute('visible_pages', collect([])); + }); + $all->each(function (Entity $entity) use ($renderPages) { $entity->setRelation('book', $this->book); diff --git a/resources/views/books/export.blade.php b/resources/views/books/export.blade.php index e86a24e81..f62b89582 100644 --- a/resources/views/books/export.blade.php +++ b/resources/views/books/export.blade.php @@ -41,9 +41,9 @@