]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Controllers/ChapterApiController.php
Update PWA manifest orientation to any
[bookstack] / app / Entities / Controllers / ChapterApiController.php
index c2132326200c5f186fdcfb82d680103a985ad20f..3fbe852220579d2b0ad36b8b7f3237d5338af658 100644 (file)
@@ -15,20 +15,22 @@ class ChapterApiController extends ApiController
 {
     protected $rules = [
         'create' => [
-            'book_id'          => ['required', 'integer'],
-            'name'             => ['required', 'string', 'max:255'],
-            'description'      => ['string', 'max:1900'],
-            'description_html' => ['string', 'max:2000'],
-            'tags'             => ['array'],
-            'priority'         => ['integer'],
+            'book_id'             => ['required', 'integer'],
+            'name'                => ['required', 'string', 'max:255'],
+            'description'         => ['string', 'max:1900'],
+            'description_html'    => ['string', 'max:2000'],
+            'tags'                => ['array'],
+            'priority'            => ['integer'],
+            'default_template_id' => ['nullable', 'integer'],
         ],
         'update' => [
-            'book_id'          => ['integer'],
-            'name'             => ['string', 'min:1', 'max:255'],
-            'description'      => ['string', 'max:1900'],
-            'description_html' => ['string', 'max:2000'],
-            'tags'             => ['array'],
-            'priority'         => ['integer'],
+            'book_id'             => ['integer'],
+            'name'                => ['string', 'min:1', 'max:255'],
+            'description'         => ['string', 'max:1900'],
+            'description_html'    => ['string', 'max:2000'],
+            'tags'                => ['array'],
+            'priority'            => ['integer'],
+            'default_template_id' => ['nullable', 'integer'],
         ],
     ];
 
@@ -134,8 +136,9 @@ class ChapterApiController extends ApiController
         $chapter->unsetRelations()->refresh();
 
         $chapter->load(['tags']);
-        $chapter->makeVisible('description_html')
-            ->setAttribute('description_html', $chapter->descriptionHtml());
+        $chapter->makeVisible('description_html');
+        $chapter->setAttribute('description_html', $chapter->descriptionHtml());
+        $chapter->setAttribute('book_slug', $chapter->book()->first()->slug);
 
         return $chapter;
     }