Skip to content

Commit 4e5c29c

Browse files
committed
Merge pull request #14 from ninjapenguin/attributes-per-spec
updates resource output to correctly nest attributes
2 parents e6c3012 + a9a0683 commit 4e5c29c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/EchoIt/JsonApi/Model.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,15 @@ public function toArray()
210210
}
211211
}
212212

213-
// add type parameter
214-
$attributes = $this->attributesToArray();
215-
$attributes['type'] = $this->getResourceType();
213+
//add type parameter
214+
$model_attributes = $this->attributesToArray();
215+
unset($model_attributes[$this->primaryKey]);
216+
217+
$attributes = [
218+
'id' => $this->getKey(),
219+
'type' => $this->getResourceType(),
220+
'attributes' => $model_attributes
221+
];
216222

217223
if (! count($relations)) {
218224
return $attributes;

0 commit comments

Comments
 (0)