1
I created a function that is called in another class to perform a task during a request in a Controller of my application.
I put a return
in that function to interrupt its execution in a specific situation. Only after that return
, the main function of Controller continues running. I then used the function dd()
of Laravel to stop all execution in this situation but, I think this function is used only for Debug.
You use this function also for specific situations in codes that are in Production or only for Debug even?
This is the function in which I inserted the dd
, that is within another class:
public function verificaItens($shipmentPed,$AuxPedido){
$pieces = explode("-", $shipmentPed);
$tagSearch = TRIM($pieces[0]).' - '.TRIM($pieces[1]);
$tag = \App\pedidosretira::where("shipment_tray",strtoupper($tagSearch))->first();
if(!isset($tag->num))
return response("Informação de Retirada '".$shipmentPed."' não
encontrada na base local da integração.", 203);
$this->num = $tag->num;
}
Below, the line calling the function inside the Controller:
$AuxPedido->verificaItens($pedido->shipment,$AuxPedido);
The Return should stop running your controller. Can you [Edit] your question and include the snippet of the controller code? About dd() you’re right, it’s more for debug. I recommend you return some kind of message to the user because only one
return;
may not make sense as a return.– gmsantos
It happens that I call this function inside a Controller but, it is in another class, it is not inside this Controller. That’s why the Controller function keeps running after this Reset. I edited the question and entered the code.
– keniaferreira