X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/495d18814a7e76cec5d8e54f7ee19ccbd47bb6c5..7f95b51b00d0d5fa1e7bcf5574f2d58bddcbd504:/app/Http/Controllers/BookController.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index 212eedc2c..b5e2a4a85 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -3,7 +3,7 @@ use Activity; use BookStack\Auth\UserRepo; use BookStack\Entities\Book; -use BookStack\Entities\EntityRepo; +use BookStack\Entities\Repos\EntityRepo; use BookStack\Entities\ExportService; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -36,18 +36,30 @@ class BookController extends Controller */ public function index() { - $books = $this->entityRepo->getAllPaginated('book', 18); + $view = setting()->getUser($this->currentUser, 'books_view_type', config('app.views.books')); + $sort = setting()->getUser($this->currentUser, 'books_sort', 'name'); + $order = setting()->getUser($this->currentUser, 'books_sort_order', 'asc'); + $sortOptions = [ + 'name' => trans('common.sort_name'), + 'created_at' => trans('common.sort_created_at'), + 'updated_at' => trans('common.sort_updated_at'), + ]; + + $books = $this->entityRepo->getAllPaginated('book', 18, $sort, $order); $recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false; $popular = $this->entityRepo->getPopular('book', 4, 0); $new = $this->entityRepo->getRecentlyCreated('book', 4, 0); - $booksViewType = setting()->getUser($this->currentUser, 'books_view_type', config('app.views.books', 'list')); + $this->setPageTitle(trans('entities.books')); return view('books/index', [ 'books' => $books, 'recents' => $recents, 'popular' => $popular, 'new' => $new, - 'booksViewType' => $booksViewType + 'view' => $view, + 'sort' => $sort, + 'order' => $order, + 'sortOptions' => $sortOptions, ]); }