]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/BookContents.php
Docker: Fix PHP tests
[bookstack] / app / Entities / Tools / BookContents.php
index cee4e79953d95af37e76e7f9f5e8dc52a9b0c15f..71c8f8393a22dff67f95a4ec931ce236d4641b49 100644 (file)
@@ -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);