Skip to content

Commit

Permalink
accounting for empty content (#64)
Browse files Browse the repository at this point in the history
* accounting for empty content

* accounting for empty content

* feat: fixing format Array

* feat: fixing format Array

---------

Co-authored-by: fernando <[email protected]>
  • Loading branch information
fernandocoronatomf and fernando authored May 14, 2023
1 parent 470d444 commit 3cf58a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/Controllers/Features/RestfulControllerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/Http/Response/Format/Json.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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']);
Expand Down

0 comments on commit 3cf58a5

Please sign in to comment.