mirror of
https://github.com/flarum/framework.git
synced 2024-12-02 06:53:47 +08:00
Update API relationship serializer/listener
This commit is contained in:
parent
9e725ca48a
commit
c371fe764b
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user