Here's an article @fideloper wrote a year ago regarding and exampling the topic
Dec 29, 2014
7
Level 8
how to know if DB::transaction failed
I have some code that runs every night as a transaction:
DB::transaction(function() {
$vitelity = new Vitelity;
$calls = $vitelity->getAllCalls();
DB::table('calls')->insert($calls);
});
I know that DB::transaction will automatically rollback if it encounters any errors, but how do I catch that it has rolled back and find out what the error is. Ill probably use mailgun to send the info to me when I can figure out how to get the info when it happens.
Level 11
Sounds like you want to know if Laravel fires an event if a rollback happens.
Looks like, yes, it just might. Try listening for event connection.rollingBack:
1 like
Please or to participate in this conversation.