Skip to content

Commit 545277e

Browse files
committed
wip
1 parent 0d43544 commit 545277e

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

src/Handler/Concerns/SavesData.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,18 @@ private function loadRelatedResources(array &$data, Request $request)
132132

133133
$value = &$data[$field->location][$name];
134134

135-
if ($field instanceof Schema\HasOne) {
136-
$value = $this->getModelForIdentifier($request, $value['data']);
137-
} elseif ($field instanceof Schema\HasMany) {
138-
$value = array_map(function ($identifier) use ($request) {
139-
return $this->getModelForIdentifier($request, $identifier);
140-
}, $value['data']);
135+
if ($field instanceof Schema\Relationship) {
136+
$value = $value['data'];
137+
138+
if ($value) {
139+
if ($field instanceof Schema\HasOne) {
140+
$value = $this->getModelForIdentifier($request, $value);
141+
} elseif ($field instanceof Schema\HasMany) {
142+
$value = array_map(function ($identifier) use ($request) {
143+
return $this->getModelForIdentifier($request, $identifier);
144+
}, $value);
145+
}
146+
}
141147
}
142148
}
143149
}

src/Handler/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function handle(Request $request): Response
8181
$paginationLinks[] = new Link\PrevLink($this->buildUrl($request, $params));
8282
}
8383

84-
if ($schema->countable) {
84+
if ($schema->countable && $schema->paginate) {
8585
$total = $adapter->count($query);
8686

8787
$members[] = new Meta('total', $total);

0 commit comments

Comments
 (0)