Level 33
1 like
In Laravel, I’m returning an API resource like this:
return (new UserResource($user))
->response()
->setStatusCode(Response::HTTP_CREATED);
This works fine, but I would also like to include a custom message in the JSON response (for example: "message" => "Successfully created").
What is the best way to add such custom fields/messages when returning API resources in Laravel?
Please or to participate in this conversation.