PHPackages                             debuqer/eloquent-memory - 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. [Caching](/categories/caching)
4. /
5. debuqer/eloquent-memory

ActiveLibrary[Caching](/categories/caching)

debuqer/eloquent-memory
=======================

Let the eloquent remember its current state of data

42PHPCI passing

Since Aug 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/debuqer/eloquent-memory)[ Packagist](https://packagist.org/packages/debuqer/eloquent-memory)[ RSS](/packages/debuqer-eloquent-memory/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (6)Used By (0)

Let the eloquent remember its current state of data
===================================================

[](#let-the-eloquent-remember-its-current-state-of-data)

[![Latest Version on Packagist](https://camo.githubusercontent.com/75c2b704933543ade479c14cf0173ee5dbb92c6aba42eab9b163af9a8110ec51/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f646562757165722f656c6f7175656e742d6d656d6f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/debuqer/eloquent-memory)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3aee7c68eb60e5a438c627928860f7d881dea12e9387b0fe70569cc556568c55/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646562757165722f656c6f7175656e742d6d656d6f72792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/debuqer/eloquent-memory/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/3406b97f13fb7dfdd95f623f76595a68736fcbde8b96c4c7ae847c34a0f33e97/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f646562757165722f656c6f7175656e742d6d656d6f72792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/debuqer/eloquent-memory/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/df393f92a96bfa387167fd7ded0152ab2d495693027acb2b9c52b11f3814152a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f646562757165722f656c6f7175656e742d6d656d6f72792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/debuqer/eloquent-memory)

Eloquent memory give you a Laravel model based time machine to perform time traveling through your models state.

```
$article = Article::create([
    'name' => 'Women, Life, Freedom',
    'content' => 'Hey this content just added,',
]);

// 5 minutes later

// let's change the content
$article->update([
    'content' => 'Hey this content just changed,'
]);

//
// Oops, we have changed our content by mistake, let's go back
$articleBeforeUpdate = $article->getStatyeOf(Carbon::now()->subMinutes(2));
$articleBeforeUpdate->save(); // will rollback the content of article to the 1 minute ago
```

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

[](#installation)

You can install the package via composer:

```
composer require debuqer/eloquent-memory
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="eloquent-memory-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="eloquent-memory-config"
```

This is the contents of the published config file:

```
return [
    'changes' => [
        'model-updated' => ModelUpdated::class,
        'model-created' => ModelCreated::class,
        'model-deleted' => ModelDeleted::class,
    ],
    'drivers' => [
        'default' => 'eloquent',

        'eloquent' => [
            'class_name' => \Debuqer\EloquentMemory\Repositories\Eloquent\EloquentTransitionPersistDriver::class,
            'connection' => 'default',
        ],
    ],
];
```

Usage
-----

[](#usage)

In order to force models to keep track of their states, *CanRememberStates* trait must be used in the model class

```
use Debuqer\EloquentMemory\CanRememberStates;

class Post extends Model
{
    use CanRememberStates;
}
```

The model records their states in a database and the states can be retrieved by method *getStateOf*

```
$oldArticle = Article::find(5)->getStateOf(Carbon::now()->subMinutes(5));
```

Road map
--------

[](#road-map)

1. Fix migration, so the subject\_key should be provide as an array
2. Fix migration to be publishable via laravel
3. no date\_recorded field are stored

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

This package is in dev mode and not recommend to use in production environment

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [debuqer](https://github.com/debuqer)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

16

—

LowBetter than 4% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/24442370?v=4)[Bagher Abbasi](/maintainers/debuqer)[@debuqer](https://github.com/debuqer)

---

Top Contributors

[![debuqer](https://avatars.githubusercontent.com/u/24442370?v=4)](https://github.com/debuqer "debuqer (77 commits)")

### Embed Badge

![Health badge](/badges/debuqer-eloquent-memory/health.svg)

```
[![Health](https://phpackages.com/badges/debuqer-eloquent-memory/health.svg)](https://phpackages.com/packages/debuqer-eloquent-memory)
```

###  Alternatives

[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

33136.2k](/packages/beryllium-cachebundle)

PHPackages © 2026

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