diff --git a/src/Http/Controllers/Features/RestfulControllerTrait.php b/src/Http/Controllers/Features/RestfulControllerTrait.php index 5261400..38b953d 100644 --- a/src/Http/Controllers/Features/RestfulControllerTrait.php +++ b/src/Http/Controllers/Features/RestfulControllerTrait.php @@ -113,7 +113,7 @@ protected function shouldTransform() protected function prependResponseMessage($response, $message) { $content = $response->getOriginalContent(); - $content['message'] = $message . $content['message']; + $content['message'] = $message . \Illuminate\Support\Arr::get($content, 'message', ''); $response->setContent($content); return $response; diff --git a/src/Http/Response/Format/Json.php b/src/Http/Response/Format/Json.php index 37332fa..3681014 100644 --- a/src/Http/Response/Format/Json.php +++ b/src/Http/Response/Format/Json.php @@ -2,6 +2,7 @@ namespace Specialtactics\L5Api\Http\Response\Format; +use Illuminate\Support\Collection; use Specialtactics\L5Api\APIBoilerplate; class Json extends \Dingo\Api\Http\Response\Format\Json @@ -14,6 +15,10 @@ class Json extends \Dingo\Api\Http\Response\Format\Json */ public function formatArray($content) { + if ($content instanceof Collection) { + $content = $content->toArray(); + } + if (array_key_exists('meta', $content) && is_array($content['meta'])) { // Change key-case of meta $content['meta'] = APIBoilerplate::formatKeyCaseAccordingToResponseFormat($content['meta']);