From: Dan Brown Date: Sun, 21 Mar 2021 21:52:39 +0000 (+0000) Subject: Merge branch 'feature/sort-shelf-books' of git://github.com/guillaumehanotel/BookStac... X-Git-Tag: v21.04~1^2~9 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/ab4c5a55b8305a125ad8610a55361d976541ec60?ds=inline;hp=--cc Merge branch 'feature/sort-shelf-books' of git://github.com/guillaumehanotel/BookStack into guillaumehanotel-feature/sort-shelf-books --- ab4c5a55b8305a125ad8610a55361d976541ec60 diff --cc app/Http/Controllers/BookshelfController.php index 8574c1b48,6c090a26d..14bc9d94e --- a/app/Http/Controllers/BookshelfController.php +++ b/app/Http/Controllers/BookshelfController.php @@@ -101,9 -101,18 +101,18 @@@ class BookshelfController extends Contr $shelf = $this->bookshelfRepo->getBySlug($slug); $this->checkOwnablePermission('book-view', $shelf); + $sort = setting()->getForCurrentUser('shelf_books_sort', 'name'); + $order = setting()->getForCurrentUser('shelf_books_sort_order', 'asc'); + + $visibleShelfBooks = $shelf->visibleBooks()->get(); + $sortedVisibleShelfBooks = $visibleShelfBooks + ->sortBy($sort, SORT_REGULAR, $order === 'desc') + ->values() + ->all(); + Views::add($shelf); $this->entityContextManager->setShelfContext($shelf->id); - $view = setting()->getForCurrentUser('bookshelf_view_type', config('app.views.books')); + $view = setting()->getForCurrentUser('bookshelf_view_type'); $this->setPageTitle($shelf->getShortName()); return view('shelves.show', [