Se agrega $statusCode
This commit is contained in:
@ -5,9 +5,9 @@ use Psr\Http\Message\ResponseInterface;
|
|||||||
|
|
||||||
trait withJson
|
trait withJson
|
||||||
{
|
{
|
||||||
public function withJson(ResponseInterface $response, array|object $data = []): ResponseInterface
|
public function withJson(ResponseInterface $response, array|object $data = [], int $statusCode = 200): ResponseInterface
|
||||||
{
|
{
|
||||||
$response->getBody()->write(json_encode($data));
|
$response->getBody()->write(json_encode($data));
|
||||||
return $response->withHeader('Content-Type', 'application/json');
|
return $response->withStatus($statusCode)->withHeader('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user