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;
/**
* 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');
* @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, [
$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());
}