]> BookStack Code Mirror - bookstack/blobdiff - app/Search/SearchApiController.php
respective book and chapter structure added.
[bookstack] / app / Search / SearchApiController.php
index d1619e118672f7c0d217c4f4519ec6cbbe3458de..28a3b53e6c3d512a211b00624b8ab9cf82a1d157 100644 (file)
@@ -14,9 +14,9 @@ class SearchApiController extends ApiController
 
     protected $rules = [
         'all' => [
-            'query'  => ['required'],
-            'page'   => ['integer', 'min:1'],
-            'count'  => ['integer', 'min:1', 'max:100'],
+            'query' => ['required'],
+            'page' => ['integer', 'min:1'],
+            'count' => ['integer', 'min:1', 'max:100'],
         ],
     ];
 
@@ -50,16 +50,16 @@ class SearchApiController extends ApiController
         $this->resultsFormatter->format($results['results']->all(), $options);
 
         $data = (new ApiEntityListFormatter($results['results']->all()))
-            ->withType()->withTags()
+            ->withType()->withTags()->withRelatedData()
             ->withField('preview_html', function (Entity $entity) {
                 return [
-                    'name'    => (string) $entity->getAttribute('preview_name'),
+                    'name' => (string) $entity->getAttribute('preview_name'),
                     'content' => (string) $entity->getAttribute('preview_content'),
                 ];
             })->format();
 
         return response()->json([
-            'data'  => $data,
+            'data' => $data,
             'total' => $results['total'],
         ]);
     }