Download the PHP package moe-mizrak/transaction-builder without Composer
On this page you can find all versions of the php package moe-mizrak/transaction-builder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download moe-mizrak/transaction-builder
More information about moe-mizrak/transaction-builder
Files in moe-mizrak/transaction-builder
Package transaction-builder
Short Description TransactionBuilder
License MIT
Homepage https://github.com/moe-mizrak/transaction-builder
Informations about the package transaction-builder
TransactionBuilder
A lightweight fluent wrapper around Laravel DB::transaction() with support for retries, on-failure callbacks, and result access.
This package was created after onFailureCallback PR which is rejected since it has a breaking change, so I've created transaction-builder package which provides onFailureCallback feature and even more can be added.
Installation
Methods
make(): Create a new instance of the TransactionBuilder.attempts(int $attempts): The number of attempts to run the transaction. - default is 1.run(callable $callback): The callback to be executed within the transaction.onFailure(callable $callback): The callback to be executed if the transaction fails after all attempts.disableThrow(): Disable throwing exceptions on failure. - default is false (meaning that exceptions will be thrown as usual).result(): Get the result of the transaction. If the transaction fails, it will return null ifdisableThrow()is called, or throw an exception otherwise.
Usage
On Failure Callback
Nested Transactions
You can also do this:
💫 Contributing
Your contributions are welcome! If you'd like to improve this package, simply create a pull request with your changes. Your efforts help enhance its functionality and documentation.
If you find this package useful, please consider ⭐ it to show your support!
📜 License
Transaction Builder for Laravel is an open-sourced software licensed under the MIT license.