PHPackages                             imanghafoori/eloquent-history - 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. imanghafoori/eloquent-history

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

imanghafoori/eloquent-history
=============================

v0.0.4(3y ago)33541PHPPHP ^7.1.3

Since Aug 23Pushed 3y ago2 watchersCompare

[ Source](https://github.com/imanghafoori1/eloquent-history)[ Packagist](https://packagist.org/packages/imanghafoori/eloquent-history)[ RSS](/packages/imanghafoori-eloquent-history/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

Eloquent History Tracker
========================

[](#eloquent-history-tracker)

It keeps track of your table rows and just like git, it only records changes for each update you make.

[![Latest Stable Version](https://camo.githubusercontent.com/f1f46b9a1a1fb7dfb8bee4d98d62d2cebe1639d45f30362eeddc0513ff4cee57/68747470733a2f2f706f7365722e707567782e6f72672f696d616e676861666f6f72692f656c6f7175656e742d686973746f72792f762f737461626c65)](https://packagist.org/packages/imanghafoori/eloquent-history)

### Installation:

[](#installation)

```
composer require imanghafoori/eloquent-history

php artisan vendor:publish

php artisan migrate

```

### Usage:

[](#usage)

```
public function boot()
{
    // here we want to monitor all the table columns except 'remember_token'
    HistoryTracker::track('App/User', $except = ['remember_token']);
}
```

Note: As an alternative to registering the `Hisotry Tracker` inside service providers, you can simply use the `WithHistoryTracker` trait inside your desired model(s):

```
use Imanghafoori\EloquentHistory\WithHistoryTracker;

class User extends Authenticatable
{
    use WithHistoryTracker;

    // here we want to monitor all the table columns except 'remember_token'
    private static $historyTrackerExceptions = ['remember_token'];
    ...
}
```

\*\* Note \*\* Since this works based on eloquent model events, if you update your rows without firing events the changes would not be recorded.

This includes performing an update query without fetching the row first.

So as an example:

```
// This query can NOT be monitored.
User::update([...]);
```

### Public API:

[](#public-api)

```
// Get all the history as a nice table

HistoryTracker::getHistoryOf(Model $model, array $columns, array $importantCols = []);

// It performs a query on the data changes table and gives you a raw version of changes.

HistoryTracker::getChanges(Model $model, array $cols);

// searches the history for a value in a column.

HistoryTracker::hasEverHad($modelId, string $colName, $value, string $tableName);
```

Note: all the queries are done within the transaction to guarantee that you do not end up with inconsistent data.

The most important method is the `getHistoryOf` which accepts an eloquent object, an array of columns to be fetched and an array of columns to be counted as a change.

#### $importantCols: What it means?!

[](#importantcols-what-it-means)

Consider a situation when you have a table with 10 columns and there are 2 forms to edit column values.

For example, a form to edit `first name`, `last name`, `bio` and etc, and another form to only change password.

Ok, now you need to show the submission history of the first form.

Here you have to exclude the password column otherwise the submissions of other forms will appear in the history of the first form.

```
HistoryTracker::getChanges($user, ['first_name', 'last_name'], ['first_name', 'last_name', 'bio']);
```

Here we don't want to show bio on the table but we want to show other metadata about that, for example, the date and the username.

---

### 🙋 Contributing

[](#raising_hand-contributing)

If you find an issue or have a better way to do something, feel free to open an issue or a pull request.

### ❗ Security

[](#exclamation-security)

If you discover any security-related issues, please use the `security tab` instead of using the issue tracker.

### ⭐ Your Stars Make Us Do More ⭐

[](#star-your-stars-make-us-do-more-star)

As always if you found this package useful and you want to encourage us to maintain and work on it. Just press the star button to declare your willingness.

More from the author:
---------------------

[](#more-from-the-author)

### Laravel Microscope

[](#laravel-microscope)

💎 It automatically find bugs in your laravel app

-

---

### Laravel HeyMan

[](#laravel-heyman)

💎 It allows to write expressive code to authorize, validate and authenticate.

-

---

```
I speak to everyone in the same way, whether he is the garbage man or the president of the university.

"Albert Einstein"

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.1% 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 ~302 days

Total

4

Last Release

1183d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6961695?v=4)[Iman](/maintainers/imanghafoori1)[@imanghafoori1](https://github.com/imanghafoori1)

---

Top Contributors

[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (25 commits)")[![mehradsadeghi](https://avatars.githubusercontent.com/u/31504728?v=4)](https://github.com/mehradsadeghi "mehradsadeghi (12 commits)")[![amirsadeghi1](https://avatars.githubusercontent.com/u/26359326?v=4)](https://github.com/amirsadeghi1 "amirsadeghi1 (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")

### Embed Badge

![Health badge](/badges/imanghafoori-eloquent-history/health.svg)

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[abbasudo/laravel-purity

elegant way to add filter and sort in laravel

514330.5k1](/packages/abbasudo-laravel-purity)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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