1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Added cross-book page/chapter sorting

This commit is contained in:
Dan Brown
2015-09-06 14:35:53 +01:00
parent 411c331a62
commit e449f25cc8
12 changed files with 239 additions and 129 deletions

View File

@ -35,6 +35,16 @@ class BookRepo
return $this->book->where('slug', '=', $slug)->first();
}
/**
* Checks if a book exists.
* @param $id
* @return bool
*/
public function exists($id)
{
return $this->book->where('id', '=', $id)->exists();
}
/**
* Get a new book instance from request input.
* @param $input

View File

@ -80,4 +80,15 @@ class ChapterRepo
return $chapters;
}
public function setBookId($bookId, Chapter $chapter)
{
$chapter->book_id = $bookId;
foreach($chapter->activity as $activity) {
$activity->book_id = $bookId;
$activity->save();
}
$chapter->save();
return $chapter;
}
}

View File

@ -186,6 +186,17 @@ class PageRepo
return $query->count() > 0;
}
public function setBookId($bookId, Page $page)
{
$page->book_id = $bookId;
foreach($page->activity as $activity) {
$activity->book_id = $bookId;
$activity->save();
}
$page->save();
return $page;
}
/**
* Gets a suitable slug for the resource
*