File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ class ApiResponseSchema implements Arrayable
29
29
*
30
30
* @param [type] $result
31
31
*/
32
- public function __construct ($ result = null )
32
+ public function __construct (mixed $ result )
33
33
{
34
34
/**
35
35
* @see \Illuminate\Database\Eloquent\Collection
@@ -128,9 +128,11 @@ public function getSuccess(): bool
128
128
* @param [type] $data
129
129
* @return void
130
130
*/
131
- public function setResult ($ data = null ): void
131
+ public function setResult (mixed $ data ): void
132
132
{
133
- if ($ data instanceof AbstractPaginator || $ data instanceof AbstractCursorPaginator) {
133
+ if ($ data instanceof \ArrayObject && $ data ->count () === 0 ) {
134
+ //JsonResponse will set data to empty ArrayObject so do nothing
135
+ } else if ($ data instanceof AbstractPaginator || $ data instanceof AbstractCursorPaginator) {
134
136
$ this ->resultType = 'collection ' ;
135
137
$ this ->result = AnonymousResource::collection ($ data );
136
138
} elseif ($ data instanceof Collection || $ data instanceof ResourceCollection) {
@@ -156,7 +158,6 @@ public function setResult($data = null): void
156
158
$ this ->resultType = 'string ' ;
157
159
$ this ->message = $ data ;
158
160
} else {
159
- // dd(gettype($data));
160
161
if (gettype ($ data ) !== 'NULL ' ) {
161
162
$ this ->resultType = gettype ($ data );
162
163
}
You can’t perform that action at this time.
0 commit comments