Update API relationship serializer/listener

This commit is contained in:
Toby Zerner 2015-10-30 11:07:20 +10:30
parent 9e725ca48a
commit c371fe764b
3 changed files with 10 additions and 10 deletions

View File

@ -50,18 +50,18 @@ class TagSerializer extends AbstractSerializer
}
/**
* @return \Flarum\Api\Relationship\HasOneBuilder
* @return \Tobscure\JsonApi\Relationship
*/
protected function parent()
protected function parent($tag)
{
return $this->hasOne(TagSerializer::class);
return $this->hasOne($tag, TagSerializer::class);
}
/**
* @return \Flarum\Api\Relationship\HasOneBuilder
* @return \Tobscure\JsonApi\Relationship
*/
protected function lastDiscussion()
protected function lastDiscussion($tag)
{
return $this->hasOne(DiscussionSerializer::class);
return $this->hasOne($tag, DiscussionSerializer::class);
}
}

View File

@ -46,12 +46,12 @@ class AddDiscussionTagsRelationship
/**
* @param GetApiRelationship $event
* @return \Flarum\Api\Relationship\HasManyBuilder|null
* @return \Tobscure\JsonApi\Relationship|null
*/
public function getApiRelationship(GetApiRelationship $event)
{
if ($event->isRelationship(DiscussionSerializer::class, 'tags')) {
return $event->serializer->hasMany('Flarum\Tags\Api\Serializer\TagSerializer', 'tags');
return $event->serializer->hasMany($event->model, 'Flarum\Tags\Api\Serializer\TagSerializer', 'tags');
}
}

View File

@ -48,12 +48,12 @@ class AddForumTagsRelationship
/**
* @param GetApiRelationship $event
* @return \Flarum\Api\Relationship\HasManyBuilder|null
* @return \Tobscure\JsonApi\Relationship|null
*/
public function getApiRelationship(GetApiRelationship $event)
{
if ($event->isRelationship(ForumSerializer::class, 'tags')) {
return $event->serializer->hasMany('Flarum\Tags\Api\Serializer\TagSerializer', 'tags');
return $event->serializer->hasMany($event->model, 'Flarum\Tags\Api\Serializer\TagSerializer', 'tags');
}
}