X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ef1b98019a0c3f123b0add8428292807eac3fe05..refs/pull/2522/head:/app/Entities/Tools/BookContents.php 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);