use BookStack\Activity\ActivityType;
use BookStack\Activity\Models\View;
use BookStack\Activity\Tools\UserEntityWatchOptions;
-use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Queries\BookQueries;
+use BookStack\Entities\Queries\BookshelfQueries;
use BookStack\Entities\Repos\BookRepo;
use BookStack\Entities\Tools\BookContents;
use BookStack\Entities\Tools\Cloner;
protected ShelfContext $shelfContext,
protected BookRepo $bookRepo,
protected BookQueries $queries,
+ protected BookshelfQueries $shelfQueries,
protected ReferenceFetcher $referenceFetcher,
) {
}
/**
* Show the form for creating a new book.
*/
- public function create(string $shelfSlug = null)
+ public function create(?string $shelfSlug = null)
{
$this->checkPermission('book-create-all');
$bookshelf = null;
if ($shelfSlug !== null) {
- $bookshelf = Bookshelf::visible()->where('slug', '=', $shelfSlug)->firstOrFail();
+ $bookshelf = $this->shelfQueries->findVisibleBySlugOrFail($shelfSlug);
$this->checkOwnablePermission('bookshelf-update', $bookshelf);
}
* @throws ImageUploadException
* @throws ValidationException
*/
- public function store(Request $request, string $shelfSlug = null)
+ public function store(Request $request, ?string $shelfSlug = null)
{
$this->checkPermission('book-create-all');
$validated = $this->validate($request, [
$bookshelf = null;
if ($shelfSlug !== null) {
- $bookshelf = Bookshelf::visible()->where('slug', '=', $shelfSlug)->firstOrFail();
+ $bookshelf = $this->shelfQueries->findVisibleBySlugOrFail($shelfSlug);
$this->checkOwnablePermission('bookshelf-update', $bookshelf);
}