Skip to content

Commit

Permalink
makeResource when is_scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon committed Aug 19, 2021
1 parent 53ac4e5 commit dba3827
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/MakeResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ protected function makeResponse($data) {
private function makeResource($resourceClass, $data) {
if (Instance::instanceOf($data, Collection::class)) {
return $resourceClass::collection($data);
} else {
return new $resourceClass($data);
}

if (is_scalar($data)) {
return ['data' => [$data]];
}

return new $resourceClass($data);
}

private function requestAjax() {
Expand Down

0 comments on commit dba3827

Please sign in to comment.