My question is simple : Is it possible to set the http response code before the controller method return (if I return a php table, for json response).
I know that it's possible to do that :
return response()->json($json,HTTP_CODE);
But I want something to set the code somewhere in the controller without modifying the final return. Or do you know a way to make the native php function http_response_code working ? Because Laravel overwrite it during building the Response. Is it possible ? Or you have to do it in the return ?
I want to know if it is possible to do that or not :
public function myMethod(){
//Some code
$this->injectHttpCode(400); //or how to use native native http_response_code(400); ?
//Some code
return $this->json; //I dont want to modify that
}
I dont want any "return" in you answer, just tell me if it's not possible.