Skip to content

Commit

Permalink
bug fix in src/JsonResource.php
Browse files Browse the repository at this point in the history
  • Loading branch information
amirfaramarzi committed Aug 27, 2021
1 parent 3edb141 commit 18af5f6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/JsonResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function collection(): Response
$this->process();

if (is_null($this->perPage))
return json([
return response()->json([
'data' => $this->response ,
]);

Expand All @@ -61,7 +61,7 @@ public function collection(): Response
'perPage' => $this->perPage
]);

return json([
return response()->json([
'data' => $this->response ,
'meta' => $this->meta
]);
Expand All @@ -70,16 +70,16 @@ public function collection(): Response
public function single(): Response
{
if (is_null($this->data))
return json([
return response()->json([
'data' => []
]);

if ($this->data instanceof Collection)
return json([
return response()->json([
'data' => $this->toArray($this->data->first())
]);

return json([
return response()->json([
'data' => $this->toArray($this->data)
]);
}
Expand Down

0 comments on commit 18af5f6

Please sign in to comment.