diff --git a/app/Transformers/Pages/PageTransformer.php b/app/Transformers/Pages/PageTransformer.php index 05d6ce9..1cfe5a8 100644 --- a/app/Transformers/Pages/PageTransformer.php +++ b/app/Transformers/Pages/PageTransformer.php @@ -19,7 +19,7 @@ class PageTransformer extends TransformerAbstract { ]; protected array $availableIncludes = [ - 'children', 'parent', 'parents', 'picture', 'sections', 'sidebars', 'publications', + 'hasChildren', 'children', 'parent', 'parents', 'picture', 'sections', 'sidebars', 'publications', 'registries', 'registry', 'permissions' ]; @@ -40,6 +40,10 @@ class PageTransformer extends TransformerAbstract { ]; } + public function includeHasChildren(Page $model): Primitive { + return $this->primitive($model->children()->exists()); + } + public function includeChildren(Page $model): Collection { return $this->collection($model->children, new PageTransformer()); }