dingo / dingo/api

Dingo response is encoding eloquent model three times

Open
#1,063 1 comment 0 reactions 1 assignee Claimed by @specialtactics View on GitHub
enhancement
Dominant language
PHP
Stars
9.4k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/dingo/api/blob/master/src/Http/Response.php#L174

```
/**
* {@inheritdoc}
*/
public function setContent($content)
{
try {
return parent::setContent($content);
} catch (UnexpectedValueException $exception) {
$this->original = $content;
return $this;
}
}
```

https://github.com/dingo/api/blob/master/src/Http/Response.php#L80

```
public static function makeFromExisting(IlluminateResponse $old)
{
$new = static::create($old->getOriginalContent(), $old->getStatusCode());
$new->headers = $old->headers;
return $new;
}
```

https://github.com/dingo/api/blob/master/src/Http/Response.php#L112

```
public function morph($format = 'json')
{
$this->content = $this->getOriginalContent();
...
}
```

If $content is a eloquent model instance, it will be encoded twice before it be overridden by transformer. Three times encoding for for each response, It is a big problem, right ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.