1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-05-29 09:21:20 +03:00

Fix for getting book items

This commit is contained in:
Dan Brown 2015-07-30 23:18:48 +01:00
parent 1e2f5ded38
commit b506beac64
2 changed files with 9 additions and 4 deletions

View File

@ -33,8 +33,10 @@ class Book extends Model
{ {
$pages = $this->pages()->where('chapter_id', '=', 0)->get(); $pages = $this->pages()->where('chapter_id', '=', 0)->get();
$chapters = $this->chapters()->get(); $chapters = $this->chapters()->get();
$children = $pages->merge($chapters); foreach($chapters as $chapter) {
return $children->sortBy('priority'); $pages->push($chapter);
}
return $pages->sortBy('priority');
} }
} }

View File

@ -47,8 +47,11 @@ class BookRepo
public function destroyBySlug($bookSlug) public function destroyBySlug($bookSlug)
{ {
$book = $this->getBySlug($bookSlug); $book = $this->getBySlug($bookSlug);
foreach($book->children() as $child) { foreach($book->pages as $page) {
$child->delete(); $page->delete();
}
foreach($book->chapters as $chapter) {
$chapter->delete();
} }
$book->delete(); $book->delete();
} }