This event is fired when a relationship is to be included on an API document. If a handler wishes to control the given relationship, then it should return an instance of Tobscure\JsonApi\Relationship\BuilderInterface.
See also: AbstractSerializer::hasOne()
See also: AbstractSerializer::hasMany()
See also: https://github.com/tobscure/json-api
 /**
  * @param GetApiRelationship $event
  * @return \Tobscure\JsonApi\Relationship|null
  */
 public function getApiRelationship(GetApiRelationship $event)
 {
     if ($event->isRelationship(PostBasicSerializer::class, 'mentionedBy')) {
         return $event->serializer->hasMany($event->model, PostBasicSerializer::class, 'mentionedBy');
     }
     if ($event->isRelationship(PostBasicSerializer::class, 'mentionsPosts')) {
         return $event->serializer->hasMany($event->model, PostBasicSerializer::class, 'mentionsPosts');
     }
     if ($event->isRelationship(PostBasicSerializer::class, 'mentionsUsers')) {
         return $event->serializer->hasMany($event->model, PostBasicSerializer::class, 'mentionsUsers');
     }
 }
 /**
  * @param GetApiRelationship $event
  * @return \Tobscure\JsonApi\Relationship|null
  */
 public function getApiRelationship(GetApiRelationship $event)
 {
     if ($event->isRelationship(PostSerializer::class, 'flags')) {
         return $event->serializer->hasMany($event->model, FlagSerializer::class, 'flags');
     }
 }
 /**
  * @param PrepareApiData $event
  */
 public function GetApiRelationship(GetApiRelationship $event)
 {
     if ($event->isRelationship(ForumSerializer::class, 'links')) {
         return $event->serializer->hasMany($event->model, LinkSerializer::class, 'links');
     }
 }
Exemplo n.º 4
0
 /**
  * @param GetApiRelationship $event
  * @return \Tobscure\JsonApi\Relationship|null
  */
 public function getApiRelationship(GetApiRelationship $event)
 {
     if ($event->isRelationship(ForumSerializer::class, 'tags')) {
         return $event->serializer->hasMany($event->model, 'Flarum\\Tags\\Api\\Serializer\\TagSerializer', 'tags');
     }
 }
 /**
  * @param GetApiRelationship $event
  * @return \Tobscure\JsonApi\Relationship|null
  */
 public function getApiAttributes(GetApiRelationship $event)
 {
     if ($event->isRelationship(PostSerializer::class, 'likes')) {
         return $event->serializer->hasMany($event->model, UserBasicSerializer::class, 'likes');
     }
 }
 /**
  * @param GetApiRelationship $event
  *
  * @return \Tobscure\JsonApi\Relationship|null
  */
 public function getApiRelationship(GetApiRelationship $event)
 {
     if ($event->isRelationship(PostSerializer::class, 'moderatorNotes')) {
         return $event->serializer->hasMany($event->model, ModeratorNoteSerializer::class, 'moderatorNotes');
     }
 }