diff --git a/app/Entities/Models/Chapter.php b/app/Entities/Models/Chapter.php index d736e2108..257b19e37 100644 --- a/app/Entities/Models/Chapter.php +++ b/app/Entities/Models/Chapter.php @@ -39,15 +39,6 @@ class Chapter extends BookChild return url('/' . implode('/', $parts)); } - /** - * 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/Tools/BookContents.php b/app/Entities/Tools/BookContents.php index cee4e7995..71c8f8393 100644 --- a/app/Entities/Tools/BookContents.php +++ b/app/Entities/Tools/BookContents.php @@ -52,12 +52,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 @@