Skip to content

Commit dc77ff3

Browse files
authored
Merge pull request #6 from yuvrajsab/fix-bug-standard-response
bug: standardResponse data validation
2 parents f794453 + e2f3a8c commit dc77ff3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/Http/Controllers/ApiController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Foundation\Validation\ValidatesRequests;
1414
use Illuminate\Http\Request;
1515
use Illuminate\Routing\Controller as BaseController;
16+
use Illuminate\Support\Collection;
1617
use Illuminate\Support\Facades\Auth;
1718
use Illuminate\Support\Str;
1819
use Luezoid\Laravelcore\Constants\ErrorConstants;
@@ -124,7 +125,7 @@ public function standardResponse($data, $message = null, $httpCode = 200, $type
124125
}
125126
return response()->json([
126127
"message" => $message,
127-
"data" => $data && method_exists($data, 'toArray') ? $data->toArray() : $data,
128+
"data" => $data && ($data instanceof Collection) ? $data->toArray() : $data,
128129
"type" => $type
129130
], $httpCode);
130131
}

0 commit comments

Comments
 (0)