use BookStack\Exceptions\PermissionsException;
use BookStack\Http\Controller;
use BookStack\References\ReferenceFetcher;
+use BookStack\Util\DatabaseTransaction;
use Illuminate\Http\Request;
use Illuminate\Validation\ValidationException;
use Throwable;
$this->checkOwnablePermission('chapter-view', $chapter);
$sidebarTree = (new BookContents($chapter->book))->getTree();
- $pages = $chapter->getVisiblePages();
+ $pages = $this->entityQueries->pages->visibleForChapterList($chapter->id)->get();
+
$nextPreviousLocator = new NextPreviousContentLocator($chapter, $sidebarTree);
View::incrementFor($chapter);
$this->checkOwnablePermission('chapter-delete', $chapter);
$this->checkPermission('book-create-all');
- $book = $transformer->transformChapterToBook($chapter);
+ $book = (new DatabaseTransaction(function () use ($chapter, $transformer) {
+ return $transformer->transformChapterToBook($chapter);
+ }))->run();
return redirect($book->getUrl());
}