X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/c7a2d568bf693add30c8402d68d1f46f09a44c5b..refs/pull/2487/head:/app/Entities/Tools/BookContents.php diff --git a/app/Entities/Tools/BookContents.php b/app/Entities/Tools/BookContents.php index ae9a95f46..71c8f8393 100644 --- a/app/Entities/Tools/BookContents.php +++ b/app/Entities/Tools/BookContents.php @@ -1,10 +1,10 @@ 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);