]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Controllers/BookshelfController.php
add tests for priority
[bookstack] / app / Entities / Controllers / BookshelfController.php
index d1b752dc23eef47b5f5e8297947d2ba6d46c375b..fcfd37538724a8c653e9997e3df732011cd30243 100644 (file)
@@ -30,7 +30,7 @@ class BookshelfController extends Controller
     }
 
     /**
-     * Display a listing of the book.
+     * Display a listing of bookshelves.
      */
     public function index(Request $request)
     {
@@ -111,8 +111,9 @@ class BookshelfController extends Controller
         ]);
 
         $sort = $listOptions->getSort();
-        $sortedVisibleShelfBooks = $shelf->visibleBooks()->get()
-            ->sortBy($sort === 'default' ? 'pivot.order' : $sort, SORT_REGULAR, $listOptions->getOrder() === 'desc')
+        $sortedVisibleShelfBooks = $shelf->visibleBooks()
+            ->reorder($sort === 'default' ? 'order' : $sort, $listOptions->getOrder())
+            ->get()
             ->values()
             ->all();