Skip to content

Commit da43e4a

Browse files
committed
fix: Relationships::mapRelationships when data is empty
1 parent 1302ef2 commit da43e4a

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG-1.1.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
Release note
22
============
33

4+
# v1.1.5
5+
### Fixes
6+
- `Relationships::mapRelationships` when data is empty
7+
48
# v1.1.4
59
### Changes
610
- phpstan lvl 6 compliant

src/Resources/Concerns/Relationships.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ private function mapRelationship(
8787
}
8888
}
8989

90-
return $resource['data'];
90+
return $resource['data'] ?? [];
9191
}
9292
}

src/Resources/Relationship.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function forRelation(string $relation): self
117117
* @param \Illuminate\Http\Request $request
118118
* @param bool $included
119119
*
120-
* @return array{data: array{data?:mixed, links?:mixed, meta?:mixed}, included?: mixed, with?: mixed}
120+
* @return array{data?: array{data?:mixed, links?:mixed, meta?:mixed}, included?: mixed, with?: mixed}
121121
*/
122122
public function toArray(mixed $request, bool $included = true): array
123123
{

0 commit comments

Comments
 (0)