diff --git a/src/Support/Traits/JsonResponseTrait.php b/src/Support/Traits/JsonResponseTrait.php index bf7ec91..2962c7f 100644 --- a/src/Support/Traits/JsonResponseTrait.php +++ b/src/Support/Traits/JsonResponseTrait.php @@ -228,7 +228,7 @@ function ($response) use ($data) { return $this->formatter->response($this->formatter->paginator(...func_get_args()), $code, $headers, $option); } - if ($data instanceof Arrayable) { + if ($data instanceof Arrayable || (is_object($data) && method_exists($data, 'toJson'))) { $data = $data->toArray(); }