Skip to content

Commit a397e56

Browse files
committed
Fix unexpected JSON resource serialization.
1 parent 56a3c41 commit a397e56

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Diff for: src/Response.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ public function resolvePropertyInstances(array $props, Request $request, bool $u
130130
}
131131

132132
if ($value instanceof ResourceResponse || $value instanceof JsonResource) {
133-
$value = $value->toResponse($request)->getData(true);
133+
$value = tap($value, static function ($value) {
134+
$value->withoutWrapping();
135+
})->toResponse($request)->getData(true);
134136
}
135137

136138
if ($value instanceof Arrayable) {

Diff for: tests/Stubs/FakeResource.php

-7
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ class FakeResource extends JsonResource
1313
*/
1414
private $data;
1515

16-
/**
17-
* The "data" wrapper that should be applied.
18-
*
19-
* @var string|null
20-
*/
21-
public static $wrap = null;
22-
2316
public function __construct(array $resource)
2417
{
2518
parent::__construct(null);

0 commit comments

Comments
 (0)