Skip to content

Commit f908e0f

Browse files
authored
RemoteCustomFieldController (#110)
resolveByIdentifierValue - check if not list ... if API returned just one item, not a list
1 parent be70845 commit f908e0f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/App/Http/Controllers/RemoteCustomFieldController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,14 @@ public function resolve(RemoteType $remoteType): JsonResponse
124124
public function resolveByIdentifierValue(RemoteType $remoteType, string $identifierValue): JsonResponse
125125
{
126126
$data = $remoteType->getRemoteData($identifierValue);
127-
128127
$data = $remoteType->data_path ? Arr::get($data, $remoteType->data_path) : $data;
129128

130-
$data = collect($data)->where($remoteType->identifier_property, $identifierValue)->first();
129+
// check if not list ... if API returned just one item, not a list
130+
if (!array_is_list($data)) {
131+
$data = [ $data ];
132+
}
131133

134+
$data = collect($data)->where($remoteType->identifier_property, $identifierValue)->first();
132135
$transformed = is_array($data) ? $this->mapSingle($remoteType->mappings, $data, $remoteType->identifier_property) : $data;
133136

134137
return response()->json($transformed);

0 commit comments

Comments
 (0)