X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b0f4500c3419b10317c5e976f6bd357efdf8b049..refs/pull/2716/head:/app/Http/Controllers/BookshelfController.php diff --git a/app/Http/Controllers/BookshelfController.php b/app/Http/Controllers/BookshelfController.php index 8574c1b48..03b3cad54 100644 --- a/app/Http/Controllers/BookshelfController.php +++ b/app/Http/Controllers/BookshelfController.php @@ -101,6 +101,14 @@ class BookshelfController extends Controller $shelf = $this->bookshelfRepo->getBySlug($slug); $this->checkOwnablePermission('book-view', $shelf); + $sort = setting()->getForCurrentUser('shelf_books_sort', 'default'); + $order = setting()->getForCurrentUser('shelf_books_sort_order', 'asc'); + + $sortedVisibleShelfBooks = $shelf->visibleBooks()->get() + ->sortBy($sort === 'default' ? 'pivot.order' : $sort, SORT_REGULAR, $order === 'desc') + ->values() + ->all(); + Views::add($shelf); $this->entityContextManager->setShelfContext($shelf->id); $view = setting()->getForCurrentUser('bookshelf_view_type'); @@ -108,8 +116,11 @@ class BookshelfController extends Controller $this->setPageTitle($shelf->getShortName()); return view('shelves.show', [ 'shelf' => $shelf, + 'sortedVisibleShelfBooks' => $sortedVisibleShelfBooks, 'view' => $view, - 'activity' => Activity::entityActivity($shelf, 20, 1) + 'activity' => Activity::entityActivity($shelf, 20, 1), + 'order' => $order, + 'sort' => $sort ]); }