use BookStack\Repos\BookRepo;
use BookStack\Repos\ChapterRepo;
use BookStack\Repos\PageRepo;
+use Views;
class BookController extends Controller
{
*/
public function index()
{
- $books = $this->bookRepo->getAll();
- return view('books/index', ['books' => $books]);
+ $books = $this->bookRepo->getAllPaginated(10);
+ $recents = $this->signedIn ? $this->bookRepo->getRecentlyViewed(4, 0) : false;
+ $popular = $this->bookRepo->getPopular(4, 0);
+ return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular]);
}
/**
public function show($slug)
{
$book = $this->bookRepo->getBySlug($slug);
- return view('books/show', ['book' => $book, 'current' => $book]);
+ Views::add($book);
+ $bookChildren = $this->bookRepo->getChildren($book);
+ return view('books/show', ['book' => $book, 'current' => $book, 'bookChildren' => $bookChildren]);
}
/**
{
$this->checkPermission('book-update');
$book = $this->bookRepo->getBySlug($bookSlug);
+ $bookChildren = $this->bookRepo->getChildren($book);
$books = $this->bookRepo->getAll();
- return view('books/sort', ['book' => $book, 'current' => $book, 'books' => $books]);
+ return view('books/sort', ['book' => $book, 'current' => $book, 'books' => $books, 'bookChildren' => $bookChildren]);
}
public function getSortItem($bookSlug)
{
$book = $this->bookRepo->getBySlug($bookSlug);
- return view('books/sort-box', ['book' => $book]);
+ $bookChildren = $this->bookRepo->getChildren($book);
+ return view('books/sort-box', ['book' => $book, 'bookChildren' => $bookChildren]);
}
/**
$isPage = $bookChild->type == 'page';
$bookId = $this->bookRepo->exists($bookChild->book) ? $bookChild->book : $defaultBookId;
$model = $isPage ? $this->pageRepo->getById($id) : $this->chapterRepo->getById($id);
- $isPage ? $this->pageRepo->setBookId($bookId, $model) : $this->chapterRepo->setBookId($bookId, $model);
+ $isPage ? $this->pageRepo->changeBook($bookId, $model) : $this->chapterRepo->changeBook($bookId, $model);
$model->priority = $index;
if ($isPage) {
$model->chapter_id = ($bookChild->parentChapter === false) ? 0 : $bookChild->parentChapter;