This repository was archived by the owner on Feb 14, 2023. It is now read-only.
File tree 2 files changed +9
-5
lines changed
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change 10
10
use Helldar \ApiResponse \Wrappers \Resolver ;
11
11
use Helldar \ApiResponse \Wrappers \Success ;
12
12
use Helldar \Support \Concerns \Makeable ;
13
+ use Illuminate \Http \Resources \Json \JsonResource ;
13
14
use Symfony \Component \HttpFoundation \JsonResponse ;
14
15
15
16
final class Response implements Responsable
@@ -47,11 +48,19 @@ public static function withoutWith(): void
47
48
public static function wrapped (): void
48
49
{
49
50
self ::$ wrap = true ;
51
+
52
+ if (class_exists (JsonResource::class)) {
53
+ JsonResource::wrap ('data ' );
54
+ }
50
55
}
51
56
52
57
public static function withoutWrap (): void
53
58
{
54
59
self ::$ wrap = false ;
60
+
61
+ if (class_exists (JsonResource::class)) {
62
+ JsonResource::withoutWrapping ();
63
+ }
55
64
}
56
65
57
66
public function with (array $ with = []): Responsable
Original file line number Diff line number Diff line change 4
4
5
5
use Helldar \ApiResponse \Services \Response ;
6
6
use Illuminate \Contracts \Debug \ExceptionHandler ;
7
- use Illuminate \Http \Resources \Json \JsonResource ;
8
7
use Orchestra \Testbench \TestCase as BaseTestCase ;
9
8
use Tests \Fixtures \Concerns \Laravel \Application ;
10
9
use Tests \Fixtures \Concerns \Laravel \Exceptionable ;
@@ -49,10 +48,6 @@ protected function resolveApplicationExceptionHandler($app)
49
48
50
49
protected function setWrapping (): void
51
50
{
52
- $ this ->wrap
53
- ? JsonResource::wrap ('data ' )
54
- : JsonResource::withoutWrapping ();
55
-
56
51
$ this ->wrap
57
52
? Response::wrapped ()
58
53
: Response::withoutWrap ();
You can’t perform that action at this time.
0 commit comments