<?php namespace BookStack\Http\Controllers;
use Activity;
+use BookStack\Actions\View;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Tools\PermissionsUpdater;
use BookStack\Entities\Tools\ShelfContext;
$shelf = $this->bookshelfRepo->getBySlug($slug);
$this->checkOwnablePermission('book-view', $shelf);
- $sort = setting()->getForCurrentUser('shelf_books_sort', 'name');
+ $sort = setting()->getForCurrentUser('shelf_books_sort', 'default');
$order = setting()->getForCurrentUser('shelf_books_sort_order', 'asc');
- $visibleShelfBooks = $shelf->visibleBooks()->get();
- $sortedVisibleShelfBooks = $visibleShelfBooks
- ->sortBy($sort, SORT_REGULAR, $order === 'desc')
+ $sortedVisibleShelfBooks = $shelf->visibleBooks()->get()
+ ->sortBy($sort === 'default' ? 'pivot.order' : $sort, SORT_REGULAR, $order === 'desc')
->values()
->all();
- Views::add($shelf);
+ View::incrementFor($shelf);
$this->entityContextManager->setShelfContext($shelf->id);
$view = setting()->getForCurrentUser('bookshelf_view_type');