Skip to content

Commit

Permalink
Fix to ensure serialised document data property is always present
Browse files Browse the repository at this point in the history
  • Loading branch information
huntie committed Jul 27, 2017
1 parent 0a05f2e commit db83d98
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Serializers/JsonApiSerializer.php
Expand Up @@ -108,13 +108,15 @@ public function addLinks($key, $value = null)
*/
public function serializeToObject(): array
{
return array_filter([
'data' => $this->getPrimaryData(),
'included' => $this->getIncluded()->values()->toArray(),
'links' => $this->getLinks(),
'meta' => $this->meta,
'jsonapi' => $this->getDocumentMeta(),
]);
return array_merge(
['data' => $this->getPrimaryData()],
array_filter([
'included' => $this->getIncluded()->values()->toArray(),
'links' => $this->getLinks(),
'meta' => $this->meta,
'jsonapi' => $this->getDocumentMeta(),
])
);
}

/**
Expand Down

0 comments on commit db83d98

Please sign in to comment.