]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'feature_move_page_into_chapter' of git://github.com/philjak/BookStack...
authorDan Brown <redacted>
Tue, 29 Oct 2019 22:26:11 +0000 (22:26 +0000)
committerDan Brown <redacted>
Tue, 29 Oct 2019 22:26:11 +0000 (22:26 +0000)
app/Entities/Repos/PageRepo.php

index 0fc68f95345189d6767087f04db9ec5ace2bb673..501b19c78fa84ba712ffeee46c2c61194caa94cf 100644 (file)
@@ -306,9 +306,14 @@ class PageRepo
             throw new PermissionsException('User does not have permission to create a page within the new parent');
         }
 
+        if ($parent instanceof Chapter) {
+            $page->chapter_id = $parent->id;
+        }
+
         $page->changeBook($parent instanceof Book ? $parent->id : $parent->book->id);
         $page->rebuildPermissions();
-        return $parent;
+
+        return ($parent instanceof Book ? $parent : $parent->book);
     }
 
     /**