1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-06 12:02:45 +03:00

Shelf view: Updated books to be database sorted

Fixes issue where sorting would not match other database-sorted parts of
app due to case sensitivity differences.
Added test to cover.

For #4341
This commit is contained in:
Dan Brown
2023-06-23 16:42:40 +01:00
parent 0a485baf8b
commit 9ae17efce9
2 changed files with 29 additions and 3 deletions

View 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();