Fix for getting book items
This commit is contained in:
parent
1e2f5ded38
commit
b506beac64
2 changed files with 9 additions and 4 deletions
|
@ -33,8 +33,10 @@ class Book extends Model
|
|||
{
|
||||
$pages = $this->pages()->where('chapter_id', '=', 0)->get();
|
||||
$chapters = $this->chapters()->get();
|
||||
$children = $pages->merge($chapters);
|
||||
return $children->sortBy('priority');
|
||||
foreach($chapters as $chapter) {
|
||||
$pages->push($chapter);
|
||||
}
|
||||
return $pages->sortBy('priority');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,8 +47,11 @@ class BookRepo
|
|||
public function destroyBySlug($bookSlug)
|
||||
{
|
||||
$book = $this->getBySlug($bookSlug);
|
||||
foreach($book->children() as $child) {
|
||||
$child->delete();
|
||||
foreach($book->pages as $page) {
|
||||
$page->delete();
|
||||
}
|
||||
foreach($book->chapters as $chapter) {
|
||||
$chapter->delete();
|
||||
}
|
||||
$book->delete();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue