diff --git a/framework/core/js/forum/src/components/discussion-page.js b/framework/core/js/forum/src/components/discussion-page.js index f4356e3fd..cf29a599c 100644 --- a/framework/core/js/forum/src/components/discussion-page.js +++ b/framework/core/js/forum/src/components/discussion-page.js @@ -54,7 +54,7 @@ export default class DiscussionPage extends mixin(Component, evented) { params() { return { near: this.currentNear, - include: ['posts', 'posts.user'] + include: ['posts', 'posts.user', 'posts.user.groups'] }; } diff --git a/framework/core/src/Api/Actions/Discussions/ShowAction.php b/framework/core/src/Api/Actions/Discussions/ShowAction.php index dbbbc2302..3c59872d7 100644 --- a/framework/core/src/Api/Actions/Discussions/ShowAction.php +++ b/framework/core/src/Api/Actions/Discussions/ShowAction.php @@ -51,7 +51,7 @@ class ShowAction extends SerializeResourceAction * * @var array */ - public static $link = ['posts']; + public static $link = ['posts', 'posts.discussion']; /** * The fields that are available to be sorted by. diff --git a/framework/core/src/Api/Serializers/BaseSerializer.php b/framework/core/src/Api/Serializers/BaseSerializer.php index 6fe6a1487..b62a256f9 100644 --- a/framework/core/src/Api/Serializers/BaseSerializer.php +++ b/framework/core/src/Api/Serializers/BaseSerializer.php @@ -49,12 +49,12 @@ abstract class BaseSerializer extends SerializerAbstract $relation = $caller['function']; } - return function ($model, $include, $links) use ($serializer, $many, $relation) { + return function ($model, $include, $included, $links) use ($serializer, $many, $relation) { if ($relation instanceof Closure) { $data = $relation($model, $include); } else { if ($include) { - $data = !is_null($model->$relation) ? $model->$relation : ($many ? $model->$relation()->get() : $model->$relation()->first()); + $data = !is_null($model->$relation) ? $model->$relation : $model->$relation()->getResults(); } elseif ($many) { $relationIds = $relation.'_ids'; $data = $model->$relationIds ?: $model->$relation()->get(['id'])->fetch('id')->all(); @@ -67,7 +67,7 @@ abstract class BaseSerializer extends SerializerAbstract if ($serializer instanceof Closure) { $serializer = $serializer($model, $data); } - $serializer = new $serializer($this->actor, $links); + $serializer = new $serializer($this->actor, $included, $links); return $many ? $serializer->collection($data) : $serializer->resource($data); }; } diff --git a/framework/core/src/Api/Serializers/DiscussionSerializer.php b/framework/core/src/Api/Serializers/DiscussionSerializer.php index d5c0205b7..e5f56edaf 100644 --- a/framework/core/src/Api/Serializers/DiscussionSerializer.php +++ b/framework/core/src/Api/Serializers/DiscussionSerializer.php @@ -2,13 +2,6 @@ class DiscussionSerializer extends DiscussionBasicSerializer { - /** - * Default relations to include. - * - * @var array - */ - protected $include = ['startUser', 'lastUser']; - /** * Serialize attributes of a Discussion model for JSON output. * diff --git a/framework/core/src/Api/Serializers/PostBasicSerializer.php b/framework/core/src/Api/Serializers/PostBasicSerializer.php index 5d8cc6aa8..92370541e 100644 --- a/framework/core/src/Api/Serializers/PostBasicSerializer.php +++ b/framework/core/src/Api/Serializers/PostBasicSerializer.php @@ -9,20 +9,6 @@ class PostBasicSerializer extends BaseSerializer */ protected $type = 'posts'; - /** - * Default relations to link. - * - * @var array - */ - protected $link = ['discussion']; - - /** - * Default relations to include. - * - * @var array - */ - protected $include = ['user']; - /** * Serialize attributes of a Post model for JSON output. * diff --git a/framework/core/src/Api/Serializers/PostSerializer.php b/framework/core/src/Api/Serializers/PostSerializer.php index a85938149..491622ddc 100644 --- a/framework/core/src/Api/Serializers/PostSerializer.php +++ b/framework/core/src/Api/Serializers/PostSerializer.php @@ -2,13 +2,6 @@ class PostSerializer extends PostBasicSerializer { - /** - * Default relations to include. - * - * @var array - */ - protected $include = ['user', 'editUser', 'hideUser']; - /** * Serialize attributes of a Post model for JSON output. * diff --git a/framework/core/src/Api/Serializers/UserSerializer.php b/framework/core/src/Api/Serializers/UserSerializer.php index 95df80b96..2b6b912e5 100644 --- a/framework/core/src/Api/Serializers/UserSerializer.php +++ b/framework/core/src/Api/Serializers/UserSerializer.php @@ -2,13 +2,6 @@ class UserSerializer extends UserBasicSerializer { - /** - * Default relations to include. - * - * @var array - */ - protected $include = ['groups']; - /** * Serialize attributes of a User model for JSON output. *