Skip to content

[13.x] feat: Add a callback to be called on transaction failure #55593

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

AhmedAlaa4611
Copy link
Contributor

This PR adds a new argument to DB::transaction() that allows you to pass in a callback to be executed when the transaction fails:

DB::transaction(function () {
 // do DB stuff
}, onFailureCallback: function () {
    Notification::send($admin, new SomethingImportantBroke());
});

Original PR that reverted due to breaking changes: #55338

Reintroducing it for the next release since breaking changes are acceptable.

@AhmedAlaa4611
Copy link
Contributor Author

This PR was closed by mistake while I was pushing a fix for StyleCI complaints. I've reopened it.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@moe-mizrak
Copy link

@AhmedAlaa4611 @taylorotwell
I've already created a package for it after the original PR is reverted, you are welcome to use and contribute to it

transaction-builder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants