PHPackages                             tpenaranda/model-log - 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. tpenaranda/model-log

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

tpenaranda/model-log
====================

A Laravel 5 package to automatically log attributes changes on any of your app models.

1.4.1(6y ago)21.3k1GPL-3.0-or-laterPHPPHP ~7CI failing

Since Jan 3Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tpenaranda/model-log)[ Packagist](https://packagist.org/packages/tpenaranda/model-log)[ RSS](/packages/tpenaranda-model-log/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (13)Used By (0)

Laravel ModelLog
================

[](#laravel-modellog)

[![Latest Stable Version](https://camo.githubusercontent.com/bfd284b1b6eb94024b2bbb13b9af7a0d1d1271edde916d078c063466bd2e35e1/68747470733a2f2f706f7365722e707567782e6f72672f7470656e6172616e64612f6d6f64656c2d6c6f672f762f737461626c65)](https://packagist.org/packages/tpenaranda/model-log) [![Total Downloads](https://camo.githubusercontent.com/61e68b48890175abdea76f5bf426947b7fbdf367d31691d172c1f81b9a17a19d/68747470733a2f2f706f7365722e707567782e6f72672f7470656e6172616e64612f6d6f64656c2d6c6f672f646f776e6c6f616473)](https://packagist.org/packages/tpenaranda/model-log) [![License](https://camo.githubusercontent.com/f893dfa4f78752719df7f81647813b0c4934f6fca477f48df75c0bc88cb78574/68747470733a2f2f706f7365722e707567782e6f72672f7470656e6172616e64612f6d6f64656c2d6c6f672f6c6963656e7365)](https://packagist.org/packages/tpenaranda/model-log)

A Laravel package to automatically log attributes changes on any of your app models.

About package
-------------

[](#about-package)

This package is intended for tracking changes of your Eloquent models inside your Laravel application. A new DB table will be created and everytime a model attribute is updated an entry will be automatically created on the DB log table.

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

[](#installation)

Install package using [Composer](http://getcomposer.org).

```
$ composer require tpenaranda/model-log

```

Run migrations to create ModelLog table.

```
$ php artisan migrate

```

\[This step is not needed on Laravel &gt;= 5.5\] Add service provider and create ModelLog DB table.
---------------------------------------------------------------------------------------------------

[](#this-step-is-not-needed-on-laravel--55-add-service-provider-and-create-modellog-db-table)

Add service provider and alias in config/app.php

```
    'providers' => [
        ...
        TPenaranda\ModelLog\Providers\ModelLogServiceProvider::class,
    ],
    'aliases' => [
        ...
        'ModelLogEntry' => TPenaranda\ModelLog\ModelLogEntry::class,
        'ObservedByModelLog' => TPenaranda\ModelLog\Traits\ObservedByModelLog::class,
    ],

```

Run ModelLog command in order to create ModelLog DB table.

```
$ php artisan model-log:create-log-table

```

Usage
-----

[](#usage)

Add 'ObservedByModelLog' trait to your model and specify attributes you want to observe/track for changes.

```
use TPenaranda\ModelLog\Traits\ObservedByModelLog;

class MyModel extends Model
{
    use ObservedByModelLog;

    protected $log = ['my_attribute', 'track_this_column_too'];
}

```

Now after every update on that model, observed attributes will be logged automatically. Use `protected $log = 'all';` (notice the string, not array) to log any change.

Retrieve log entries:

```
$my_model->logEntries;

```

Advanced usage
--------------

[](#advanced-usage)

Retrieve log entries using query scopes:

```
\ModelLogEntry::whereModelClass('App\MyModel')->whereAttribute('my_attribute')->whereTo('value_after_change')->get();

```

Available scopes:

- whereModel(``): *Get logs of an specific Eloquent Model* (example: get log data of MyModel ID #4).
- whereModelClass(``): *Get logs for an specific model class* (example: get entries where MyModel class is involved, regardless of any IDs).
- whereAttribute(``): *Get only logs where some specific attribute was changed.*
- whereFrom(``): *Get only logs with an specific initial value.*
- whereTo(``): *Get only logs with an specific end value.*
- ModifiedByUser(``): *Get changes done by some specific user.* Allowed parameters: null, numeric IDs or User object.

The following scopes only accept [Carbon](http://carbon.nesbot.com) objects as parameters:

- loggedBefore(``): *Retrieve only entries logged prior to specific date.*
- loggedAfter(``): *Retrieve only entries logged after specific date.*
- withinDateRange(``, ``): *Retrieve only entries logged after first parameter and prior to second parameter.*

Create (or drop and create) ModelLog table manually:

```
$ php artisan model-log:create-log-table

```

Flush ModelLog table:

```
\ModelLogEntry::flushAll();

```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity70

Established project with proven stability

 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 ~65 days

Recently: every ~6 days

Total

12

Last Release

2327d ago

Major Versions

0.2.0 → 1.1.62018-01-22

### Community

Maintainers

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

---

Top Contributors

[![tpenaranda](https://avatars.githubusercontent.com/u/12966330?v=4)](https://github.com/tpenaranda "tpenaranda (5 commits)")

---

Tags

attributeschangescomposereloquentlaravellaravel-5-packagelaravel5loggerloggingmodeltatetrackloglaravelmodeleloquentAudithistorychangesattributestrack

### Embed Badge

![Health badge](/badges/tpenaranda-model-log/health.svg)

```
[![Health](https://phpackages.com/badges/tpenaranda-model-log/health.svg)](https://phpackages.com/packages/tpenaranda-model-log)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[altek/accountant

The auditing &amp; accountability package for Laravel's Eloquent ORM.

92954.3k4](/packages/altek-accountant)[panoscape/history

Eloquent model history tracking for Laravel

162130.3k](/packages/panoscape-history)[betapeak/laravel-auditing-filesystem

A filesystem driver for the owen-it/laravel-auditing package. Allows storage of the audits in CSV files, across all registered Laravel disks.

166.5k](/packages/betapeak-laravel-auditing-filesystem)

PHPackages © 2026

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