]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/Api/ChapterApiController.php
Added testing for our request method overrides
[bookstack] / app / Http / Controllers / Api / ChapterApiController.php
index 13b3f9821171c77f664f94e7349f4a860abe76d3..8459b84499ee362919e87833ad7527b2a7e33928 100644 (file)
@@ -14,16 +14,16 @@ class ChapterApiController extends ApiController
 
     protected $rules = [
         'create' => [
-            'book_id'     => 'required|integer',
-            'name'        => 'required|string|max:255',
-            'description' => 'string|max:1000',
-            'tags'        => 'array',
+            'book_id'     => ['required', 'integer'],
+            'name'        => ['required', 'string', 'max:255'],
+            'description' => ['string', 'max:1000'],
+            'tags'        => ['array'],
         ],
         'update' => [
-            'book_id'     => 'integer',
-            'name'        => 'string|min:1|max:255',
-            'description' => 'string|max:1000',
-            'tags'        => 'array',
+            'book_id'     => ['integer'],
+            'name'        => ['string', 'min:1', 'max:255'],
+            'description' => ['string', 'max:1000'],
+            'tags'        => ['array'],
         ],
     ];
 
@@ -70,7 +70,7 @@ class ChapterApiController extends ApiController
     public function read(string $id)
     {
         $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'ownedBy', 'pages' => function (HasMany $query) {
-            $query->visible()->get(['id', 'name', 'slug']);
+            $query->scopes('visible')->get(['id', 'name', 'slug']);
         }])->findOrFail($id);
 
         return response()->json($chapter);