Skip to content

Commit 4190288

Browse files
committed
fix(Pipes): Handle withoutWrapper method in data structures
- Check for method existence 'withoutWrapper' before calling - Ensure proper handling of non-wrapped JSON resources in JsonResourceDataPipe - Add similar logic in PaginatorDataPipe for consistency
1 parent de02833 commit 4190288

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/Pipes/JsonResourceDataPipe.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public function handle(array $structure, \Closure $next): JsonResponse
4343
&& !$structure['data']->resource instanceof AbstractPaginator
4444
) {
4545
JsonResource::withoutWrapping();
46+
method_exists($structure['data'], 'withoutWrapper') and $structure['data']->withoutWrapper();
4647
}
4748

4849
return $next($structure);

src/Pipes/PaginatorDataPipe.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ private function dataFor($data, ?string $wrap)
7272
)
7373
) {
7474
$data::wrap($wrap);
75+
method_exists($data, 'withWrapper') and $data->withWrapper($wrap);
7576
}
7677

7778
return $data;

0 commit comments

Comments
 (0)