]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/Api/BookshelfApiController.php
Added testing for our request method overrides
[bookstack] / app / Http / Controllers / Api / BookshelfApiController.php
index c29e5b0ae4c2d656843a6789503b619a278431aa..bd4f23a1093257cecd971a030d5c48109fc3a313 100644 (file)
@@ -18,14 +18,14 @@ class BookshelfApiController extends ApiController
 
     protected $rules = [
         'create' => [
-            'name'        => 'required|string|max:255',
-            'description' => 'string|max:1000',
-            'books'       => 'array',
+            'name'        => ['required', 'string', 'max:255'],
+            'description' => ['string', 'max:1000'],
+            'books'       => ['array'],
         ],
         'update' => [
-            'name'        => 'string|min:1|max:255',
-            'description' => 'string|max:1000',
-            'books'       => 'array',
+            'name'        => ['string', 'min:1', 'max:255'],
+            'description' => ['string', 'max:1000'],
+            'books'       => ['array'],
         ],
     ];
 
@@ -75,7 +75,7 @@ class BookshelfApiController extends ApiController
         $shelf = Bookshelf::visible()->with([
             'tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy',
             'books' => function (BelongsToMany $query) {
-                $query->visible()->get(['id', 'name', 'slug']);
+                $query->scopes('visible')->get(['id', 'name', 'slug']);
             },
         ])->findOrFail($id);