Answer the question
In order to leave comments, you need to log in
Why doesn't Laravel save data to DB on HttpException?
I'm trying to save data to the database, but if there is an HttpException in the code, then Laravel does not save anything. In this case, the code works fine without the last line throw new AppHttpException). Apparently there is a rollback, tk. id is incremented even if there is no entry in the table.
How to make saving and throwing an exception work together.
$order_wait = new OrderWait();
$order_wait->order_id = $order->id;
$order_wait->save();
throw new AppHttpException(null, 465071, 'user balance too low for inner contract', [$id, $user->id, $user->balance], 404);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question