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:
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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
|
||||
*
|
||||
|
Reference in New Issue
Block a user