]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'feature/sort-shelf-books' of git://github.com/guillaumehanotel/BookStac...
authorDan Brown <redacted>
Sun, 21 Mar 2021 21:52:39 +0000 (21:52 +0000)
committerDan Brown <redacted>
Sun, 21 Mar 2021 21:52:39 +0000 (21:52 +0000)
1  2 
app/Http/Controllers/BookshelfController.php
app/Http/Controllers/UserController.php

index 8574c1b48589970039ccf36aee51a4c85b0d3aaa,6c090a26da999cecbe12f7482b1e872d548d7421..14bc9d94efc61e8704f8691b368b7d56799d1f50
@@@ -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', [
Morty Proxy This is a proxified and sanitized view of the page, visit original site.