Skip to content

Commit 7085482

Browse files
committed
[Bugfix] Ensure controller create action always results in 201
Closes #101
1 parent 1a5a328 commit 7085482

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ All notable changes to this project will be documented in this file. This projec
2626
request JSON content before parsing it for compliance with the JSON:API specification. A `JsonApiException` will now
2727
be thrown instead.
2828

29+
### Fixed
30+
31+
- [#101](https://github.com/laravel-json-api/laravel/issues/101) Ensure controller create action always returns a
32+
response that will result in a `201 Created` response.
33+
2934
## [1.0.0-beta.4] - 2021-06-02
3035

3136
### Fixed

src/Http/Controllers/Actions/Store.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public function store(Route $route, StoreContract $store)
7171
$response = $this->saved($model, $request, $query);
7272
}
7373

74-
return $response ?: DataResponse::make($model)->withQueryParameters($query);
74+
return $response ?? DataResponse::make($model)
75+
->withQueryParameters($query)
76+
->didCreate();
7577
}
7678
}

0 commit comments

Comments
 (0)