]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Models/BookChild.php
Extend /users API endpoint
[bookstack] / app / Entities / Models / BookChild.php
index f05a25499b03bc3a0cf2e688f62ef2c26d9f2717..c73fa3959423598da0e1619c07d9720760374a39 100644 (file)
@@ -1,4 +1,4 @@
-<?php namespace BookStack\Entities;
+<?php namespace BookStack\Entities\Models;
 
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -28,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();
     }
 
     /**
@@ -47,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);
             }
         }