I am working with a laravel project and willing to implement the best practice of web development. For some ajax requests, I am returning json response. For example, when I delete a record, I return 204
http status code
return response()->json([], 204);
But when I delete a record, I want to make sure the delete operation was successful. If the operation is not successful, I want to return a different status code and I want to know which status code is most appropriate for this case?
My code example is
if($department->delete()){
//delete success and return 204
return response()->json([], 204);
}else{
//delete is not success, what is appropriate status code for this?
return response()->json([], 500);
}