PHPackages                             fish/eloquent-logger - 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. fish/eloquent-logger

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

fish/eloquent-logger
====================

Log Eloquent model changes to a designated logs table

1.3.2(10y ago)814.0k3[2 issues](https://github.com/matfish2/eloquent-logger/issues)MITPHPPHP &gt;=5.4.0

Since Jan 30Pushed 8y ago2 watchersCompare

[ Source](https://github.com/matfish2/eloquent-logger)[ Packagist](https://packagist.org/packages/fish/eloquent-logger)[ RSS](/packages/fish-eloquent-logger/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (7)Used By (0)

Eloquent Logger
===============

[](#eloquent-logger)

[![Latest Stable Version](https://camo.githubusercontent.com/c88f983831d58d4753851497f470cd0476bcf63615e5d6249fe0faa1679b53df/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d6c6f676765722f762f737461626c65)](https://packagist.org/packages/fish/eloquent-logger) [![Total Downloads](https://camo.githubusercontent.com/ff855831ef4f9f654fc2044a14643bd26311bb45df7ef413ff7f09b0980c83e6/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d6c6f676765722f646f776e6c6f616473)](https://packagist.org/packages/fish/eloquent-logger) [![Latest Unstable Version](https://camo.githubusercontent.com/7156804d95ff0458d4ba424a64beca879d25b6dd23afaf42132edba1813c1d66/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d6c6f676765722f762f756e737461626c65)](https://packagist.org/packages/fish/eloquent-logger) [![License](https://camo.githubusercontent.com/2438f6d8d7a1108caa53afe4aa77d83cf639522ed079cbbfe5ab75c240066387/68747470733a2f2f706f7365722e707567782e6f72672f666973682f656c6f7175656e742d6c6f676765722f6c6963656e7365)](https://packagist.org/packages/fish/eloquent-logger)

This Laravel 5 package adds logging functionality to Eloquent models. All changes (create, update, delete) will be recorded in a designated logs table. Updates will record only dirty fields.

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

[](#installation)

Add to `composer.json`:

```
"require": {
  "fish/eloquent-logger": "^1.0"
}

```

Update Composer from the Terminal:

```
composer update

```

Add the service provider to the the list of providers in your `app.php`

```
Fish\Logger\LoggerServiceProvider

```

Publish migration:

```
php artisan logger:init

```

Run migration:

```
php artisan migrate

```

Usage
-----

[](#usage)

Use the trait on relevant models. E.g:

```
namespace App;

use Illuminate\Database\Eloquent\Model;
use Fish\Logger\Logger;

class Post extends Model
{
  use Logger;
}

```

Retrieving logs for a model:

```
Post::find(1)->logs

```

Retrieving model from log (if the action was not `deleted`):

```
Fish\Logger\Log::find(1)->loggable;

```

Retrieve the state of the model at a certain point of time:

```
Post::find(1)->logs()->stateOn('2015-02-02 13:00:00');

```

To retrieve the state of a deleted model:

```
Fish\Logger\Log::entity(Post::class, 1)->stateOn('2016-01-01 12:00:00');

```

The model will be retrieved even if the passed timestamp occured after it was already deleted.

The Log contains the following properties:

- `user_id` `integer`: User who did the action. if there is no authenticated user, set to `null`
- `action` `string`: type of action - `created`, `updated` or `deleted`
- `before` `array`: state of the model before the action. If the action is `created` set to `null`
- `after` `array`: state of the model after the action. If the action is `deleted` set to `null`
- `created_at` `datetime`: action's timestamp

### Query helpers

[](#query-helpers)

- `wasCreated`, `wasUpdated` or `wasDeleted` - filter by action.
- `between` - filter by date range.

Example:

```
Post::find(1)->logs()
            ->wasUpdated()
            ->between('2015-01-01','2015-02-01')
            ->get();

```

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% 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 ~13 days

Total

6

Last Release

3686d ago

### Community

Maintainers

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

---

Top Contributors

[![matfish2](https://avatars.githubusercontent.com/u/1510460?v=4)](https://github.com/matfish2 "matfish2 (22 commits)")[![rettigd](https://avatars.githubusercontent.com/u/875977?v=4)](https://github.com/rettigd "rettigd (1 commits)")

---

Tags

loglaraveleventsmodeleloquent

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fish-eloquent-logger/health.svg)

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M70](/packages/mongodb-laravel-mongodb)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spiritix/lada-cache

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

591444.8k2](/packages/spiritix-lada-cache)[panoscape/history

Eloquent model history tracking for Laravel

162130.3k](/packages/panoscape-history)[pdphilip/elasticsearch

An Elasticsearch implementation of Laravel's Eloquent ORM

145360.2k4](/packages/pdphilip-elasticsearch)

PHPackages © 2026

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