X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/14ea6c9de341a5474210bc8dba862a23c5de7bf0..refs/pull/3377/head:/app/Entities/Models/BookChild.php diff --git a/app/Entities/Models/BookChild.php b/app/Entities/Models/BookChild.php index 8b968cc8b..e1ba0b6f7 100644 --- a/app/Entities/Models/BookChild.php +++ b/app/Entities/Models/BookChild.php @@ -1,23 +1,38 @@ -addSelect(['book_slug' => function ($builder) { + $builder->select('slug') + ->from('books') + ->whereColumn('books.id', '=', 'book_id'); + }]); + }); + } /** - * Scope a query to find items where the the child has the given childSlug + * Scope a query to find items where the child has the given childSlug * where its parent has the bookSlug. */ public function scopeWhereSlugs(Builder $query, string $bookSlug, string $childSlug) @@ -49,7 +64,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); } }