PHPackages                             astrotomic/laravel-transaction-proxy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. astrotomic/laravel-transaction-proxy

ActiveLibrary[Database &amp; ORM](/categories/database)

astrotomic/laravel-transaction-proxy
====================================

This package provides a trait and class to call methods in a database transaction.

0.3.0(5y ago)51.3kMITPHPPHP ^7.4 || ^8.0

Since Aug 18Pushed 4y ago2 watchersCompare

[ Source](https://github.com/Astrotomic/laravel-transaction-proxy)[ Packagist](https://packagist.org/packages/astrotomic/laravel-transaction-proxy)[ Docs](https://github.com/Astrotomic/laravel-transaction-proxy)[ Fund](https://offset.earth/treeware)[ GitHub Sponsors](https://github.com/Gummibeer)[ RSS](/packages/astrotomic-laravel-transaction-proxy/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

Laravel Transaction Proxy
=========================

[](#laravel-transaction-proxy)

[![Latest Version](https://camo.githubusercontent.com/5c88059adc7bf4db4d87aac9758f33d3265def86e7e7873ac81ecfda067c3422/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617374726f746f6d69632f6c61726176656c2d7472616e73616374696f6e2d70726f78792e7376673f6c6162656c3d52656c65617365267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/astrotomic/laravel-transaction-proxy)[![MIT License](https://camo.githubusercontent.com/fc88e15f5044695321147648e4a8a5cd194008e6750e1aa7dd37ed469b970e3a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f417374726f746f6d69632f6c61726176656c2d7472616e73616374696f6e2d70726f78792e7376673f6c6162656c3d4c6963656e736526636f6c6f723d626c7565267374796c653d666f722d7468652d6261646765)](https://github.com/Astrotomic/laravel-transaction-proxy/blob/master/LICENSE)[![Offset Earth](https://camo.githubusercontent.com/d204555ebe1fb0ae82d10c97b4f4ffc2dfdd2ba1489f98be7f7e8708333a0466/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d677265656e3f7374796c653d666f722d7468652d6261646765)](https://plant.treeware.earth/Astrotomic/laravel-transaction-proxy)

[![GitHub Workflow Status](https://camo.githubusercontent.com/2b7da571f6490dc75801f568d30219e6868a395ae9d22ea397498e9e4dfde7f8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f417374726f746f6d69632f6c61726176656c2d7472616e73616374696f6e2d70726f78792f72756e2d74657374733f7374796c653d666c61742d737175617265266c6f676f436f6c6f723d7768697465266c6f676f3d676974687562266c6162656c3d5465737473)](https://github.com/Astrotomic/laravel-transaction-proxy/actions?query=workflow%3Arun-tests)[![StyleCI](https://camo.githubusercontent.com/9efa3ad692bc2a8f8728eccf10683a7813f6e83ea0fe70cd68caf2c12d1861ea/68747470733a2f2f7374796c6563692e696f2f7265706f732f3238383435383636392f736869656c64)](https://styleci.io/repos/288458669)[![Total Downloads](https://camo.githubusercontent.com/689532f8706b06a2add23603a9854d858ceb4a8e4f56be30f5f74a1c36120e71/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617374726f746f6d69632f6c61726176656c2d7472616e73616374696f6e2d70726f78792e7376673f6c6162656c3d446f776e6c6f616473267374796c653d666c61742d737175617265)](https://packagist.org/packages/astrotomic/laravel-transaction-proxy)

This package provides a trait and class to call methods in a database transaction. This is useful if you have any listeners also running database queries, like deleting child models.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require astrotomic/laravel-transaction-proxy
```

Usage
-----

[](#usage)

The easiest will be to use the `\Astrotomic\LaravelTransactionProxy\HasTransactionCalls` trait which adds a `transaction()` method.

```
use Astrotomic\LaravelTransactionProxy\HasTransactionalCalls;

class MyClass
{
    use HasTransactionalCalls;
}
```

### Transaction chained Method

[](#transaction-chained-method)

You can call the `transaction()` without any argument and the method after will be called in a transaction.

This example will call the `delete()` method in a transaction. This is useful if you have any listeners also running database queries, like deleting child models. The transaction will prevent you from corrupted data if any of the queries fails.

```
$model->transaction()->delete();

// vs

use Illuminate\Support\Facades\DB;
DB::transaction(fn() => $model->delete());
```

### Conditional Callback

[](#conditional-callback)

If you want you can also pass a callback to the `transaction()` method you will get the calling object as first argument.

```
$model->transaction(function(Model $model) {
    $model->update();
    $model->child->update();
});
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/Astrotomic/.github/blob/master/CONTRIBUTING.md) for details. You could also be interested in [CODE OF CONDUCT](https://github.com/Astrotomic/.github/blob/master/CODE_OF_CONDUCT.md).

### Security

[](#security)

If you discover any security related issues, please check [SECURITY](https://github.com/Astrotomic/.github/blob/master/SECURITY.md) for steps to report it.

Credits
-------

[](#credits)

- [Tom Witkowski](https://github.com/Gummibeer)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Treeware
--------

[](#treeware)

You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees at [offset.earth/treeware](https://plant.treeware.earth/Astrotomic/laravel-transaction-proxy)

Read more about Treeware at [treeware.earth](https://treeware.earth)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~31 days

Total

4

Last Release

2000d ago

PHP version history (2 changes)0.1.0PHP ^7.4

0.3.0PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb5d60f7dd33ef3680490f11b3cd461b0c7a5dcddfe69d57fb1f6a3406be4570?d=identicon)[Gummibeer](/maintainers/Gummibeer)

---

Top Contributors

[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (24 commits)")

---

Tags

eloquenthacktoberfestlaraveltransactiontreewarelaravelproxydatabaseeloquentdatabase transactiontransaction-proxy

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/astrotomic-laravel-transaction-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/astrotomic-laravel-transaction-proxy/health.svg)](https://phpackages.com/packages/astrotomic-laravel-transaction-proxy)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[czim/laravel-filter

Filter for Laravel Eloquent queries, with support for modular filter building

8973.0k3](/packages/czim-laravel-filter)[eusonlito/laravel-database-cache

Cache Database Query results on Laravel Query Builder or Eloquent

194.2k](/packages/eusonlito-laravel-database-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
