Skip to content

Commit

Permalink
update: accepted/created
Browse files Browse the repository at this point in the history
  • Loading branch information
jiannei committed Oct 14, 2023
1 parent 63b733a commit 91fb374
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/Support/Traits/JsonResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ trait JsonResponseTrait
*/
public function accepted($data = [], string $message = '', string $location = ''): JsonResponse
{
$response = $this->success($data, $message, 202);
if ($location) {
$response->header('Location', $location);
}

return $response;
return tap($this->success($data, $message, 202), function ($response) use ($location) {
if ($location) {
$response->header('Location', $location);
}
});
}

/**
Expand All @@ -44,12 +43,11 @@ public function accepted($data = [], string $message = '', string $location = ''
*/
public function created($data = [], string $message = '', string $location = ''): JsonResponse
{
$response = $this->success($data, $message, 201);
if ($location) {
$response->header('Location', $location);
}

return $response;
return tap($this->success($data, $message, 201), function ($response) use ($location) {
if ($location) {
$response->header('Location', $location);
}
});
}

/**
Expand Down

0 comments on commit 91fb374

Please sign in to comment.