]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/BookController.php
Added language list favourites sorting, updated styles
[bookstack] / app / Http / Controllers / BookController.php
index 937f7d28f1817670bf4af3a18135bbf0aaf2362e..c5b6d0bf6def5ee529769aba77de0c8e42194ad1 100644 (file)
@@ -88,10 +88,11 @@ class BookController extends Controller
     public function store(Request $request, string $shelfSlug = null)
     {
         $this->checkPermission('book-create-all');
-        $this->validate($request, [
+        $validated = $this->validate($request, [
             'name'        => ['required', 'string', 'max:255'],
             'description' => ['string', 'max:1000'],
             'image'       => array_merge(['nullable'], $this->getImageValidationRules()),
+            'tags'        => ['array'],
         ]);
 
         $bookshelf = null;
@@ -100,7 +101,7 @@ class BookController extends Controller
             $this->checkOwnablePermission('bookshelf-update', $bookshelf);
         }
 
-        $book = $this->bookRepo->create($request->all());
+        $book = $this->bookRepo->create($validated);
 
         if ($bookshelf) {
             $bookshelf->appendBook($book);
@@ -163,11 +164,12 @@ class BookController extends Controller
             'name'        => ['required', 'string', 'max:255'],
             'description' => ['string', 'max:1000'],
             'image'       => array_merge(['nullable'], $this->getImageValidationRules()),
+            'tags'        => ['array'],
         ]);
 
         if ($request->has('image_reset')) {
             $validated['image'] = null;
-        } else if (array_key_exists('image', $validated) && is_null($validated['image'])) {
+        } elseif (array_key_exists('image', $validated) && is_null($validated['image'])) {
             unset($validated['image']);
         }