Add enum with http status codes #47333
-
I personally write APIs with Laravel very often, so I also need the HTTP status codes very often. I have already prepared a suitable branch for this in my fork: https://github.com/christophstockinger/laravel-framework/tree/feat/enum-http-status-codes I also add a PR #47334 An example for the usage would be: public function index(Request $request) {
// ... some databse logic ...
return response()->json(['some data'], HttpStatus::OK)
}
public function store($data, Request $request) {
// ... some databse logic ...
return response()->json(['created data'], HttpStatus::CREATED)
} I look forward to feedback on the feature request as well as feedback on the code. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
It should be Also, there are constants you can use in the Symfony Response class |
Beta Was this translation helpful? Give feedback.
-
Henzeb is right , you can use Symfony Response's consts . Symfony\Component\HttpFoundation\Response All statuses are defined there . |
Beta Was this translation helpful? Give feedback.
Here the link, for convenience: https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/HttpFoundation/Response.php