X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/546cfb0dcc801c4fa6560ca0e6d18b4f1edd830f..refs/pull/5721/head:/app/Entities/Controllers/BookController.php diff --git a/app/Entities/Controllers/BookController.php b/app/Entities/Controllers/BookController.php index a0b98636f..5d3d67f64 100644 --- a/app/Entities/Controllers/BookController.php +++ b/app/Entities/Controllers/BookController.php @@ -6,7 +6,6 @@ use BookStack\Activity\ActivityQueries; 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; @@ -19,6 +18,7 @@ use BookStack\Exceptions\NotFoundException; use BookStack\Facades\Activity; use BookStack\Http\Controller; use BookStack\References\ReferenceFetcher; +use BookStack\Util\DatabaseTransaction; use BookStack\Util\SimpleListOptions; use Illuminate\Http\Request; use Illuminate\Validation\ValidationException; @@ -71,7 +71,7 @@ class BookController extends Controller /** * 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'); @@ -94,7 +94,7 @@ class BookController extends Controller * @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, [ @@ -264,7 +264,9 @@ class BookController extends Controller $this->checkPermission('bookshelf-create-all'); $this->checkPermission('book-create-all'); - $shelf = $transformer->transformBookToShelf($book); + $shelf = (new DatabaseTransaction(function () use ($book, $transformer) { + return $transformer->transformBookToShelf($book); + }))->run(); return redirect($shelf->getUrl()); }