]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Models/BookChild.php
Extend /users API endpoint
[bookstack] / app / Entities / Models / BookChild.php
index 91f62dc403c64fdde0079b223e4574bd84199251..c73fa3959423598da0e1619c07d9720760374a39 100644 (file)
@@ -1,8 +1,5 @@
 <?php namespace BookStack\Entities\Models;
 
-use BookStack\Entities\Models\Chapter;
-use BookStack\Entities\Models\Entity;
-use BookStack\Entities\Models\Book;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
 
@@ -31,11 +28,10 @@ abstract class BookChild extends Entity
 
     /**
      * Get the book this page sits in.
-     * @return BelongsTo
      */
     public function book(): BelongsTo
     {
-        return $this->belongsTo(Book::class);
+        return $this->belongsTo(Book::class)->withTrashed();
     }
 
     /**
@@ -50,7 +46,7 @@ abstract class BookChild extends Entity
 
         // Update all child pages if a chapter
         if ($this instanceof Chapter) {
-            foreach ($this->pages as $page) {
+            foreach ($this->pages()->withTrashed()->get() as $page) {
                 $page->changeBook($newBookId);
             }
         }