-2
public function finalizarCompra () {
try {
$compra = Compra::findOrFail($compra->id);
}
catch(ModelNotFoundException $e){
return "erro";
}
}
-2
public function finalizarCompra () {
try {
$compra = Compra::findOrFail($compra->id);
}
catch(ModelNotFoundException $e){
return "erro";
}
}
2
Caleb,
If your function returns false vc you need to force an error with throw, follow:
public function finalizarCompra () {
try {
$compra = Compra::findOrFail($compra->id);
if (!$compra) {
throw new Exception('Não encontrado');
}
}
catch(ModelNotFoundException $e){
return "erro";
}
}
Browser other questions tagged php laravel
You are not signed in. Login or sign up in order to post.
What happens in this case? an Exception is launched?
– rray
can already solve my problem ! rray, I am beginner in programming I managed to solve now !
– Caleb