PHPackages                             asif/laravel-model-logs - 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. asif/laravel-model-logs

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

asif/laravel-model-logs
=======================

v1.0.0(2y ago)311PHP

Since Jul 30Pushed 2y ago1 watchersCompare

[ Source](https://github.com/asifzcpe/lara-model-logs)[ Packagist](https://packagist.org/packages/asif/laravel-model-logs)[ RSS](/packages/asif-laravel-model-logs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Laravel Model Logs
==================

[](#laravel-model-logs)

The laravel-model-logs package provides an easy way to track changes made to your Eloquent models and log them into an `audit_logs` table. It allows you to keep a history of all the modifications made to your models, making it useful for auditing purposes, user activity tracking, and more.

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

[](#installation)

You can install the package via Composer by running the following command:

```
composer require asif/laravel-model-logs
```

After installing the package, Laravel will automatically discover the service provider.

Usage
-----

[](#usage)

### Step 1: Set up the Database

[](#step-1-set-up-the-database)

Before using the package, you need to create the audit\_logs table in your database. You can use the provided migration file to create the table by running the migration:

```
php artisan migrate
```

### Step 2: Add the LogChanges Trait to Your Models

[](#step-2-add-the-logchanges-trait-to-your-models)

To start tracking changes on your models, add the LogChanges trait to each model you want to monitor. The trait provides the necessary functionality to automatically log changes whenever the model is created, updated, or deleted.

```
use Asif\LaravelModelLogs\Traits\LogChanges;
use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    use LogChanges;

    // Rest of your model code...
}
```

### Step 3: Customize Tracked Events (Optional)

[](#step-3-customize-tracked-events-optional)

By default, the LogChanges trait tracks all events: 'created', 'updated', and 'deleted'. However, you can customize the tracked events for each model by adding a $trackedEvents property to the model. If the property is not defined, the package will track all events.

```
use Asif\LaravelModelLogs\Traits\LogChanges;
use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    use LogChanges;

    /**
     * Customize the tracked events for this model.
     *
     * @var array
     */
    protected $trackedEvents = ['created', 'updated'];

    // Rest of your model code...
}
```

### Step 4: Define Loggable Fields (Optional)

[](#step-4-define-loggable-fields-optional)

You can further customize the fields that should be logged for each model by adding a $loggable property to the model, containing an array of field names that you want to track. If the property is not provided, the package will log all the fields.

```
use Asif\LaravelModelLogs\Traits\LogChanges;
use Illuminate\Database\Eloquent\Model;

class YourModel extends Model
{
    use LogChanges;

    /**
     * The attributes that should be logged in the audit log.
     *
     * @var array
     */
    protected $loggable = ['name', 'email'];

    // Rest of your model code...
}
```

License
-------

[](#license)

The laravel-model-logs package is open-sourced software licensed under the MIT License.

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

1016d ago

### Community

Maintainers

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

---

Top Contributors

[![asifzcpe](https://avatars.githubusercontent.com/u/22665561?v=4)](https://github.com/asifzcpe "asifzcpe (1 commits)")

### Embed Badge

![Health badge](/badges/asif-laravel-model-logs/health.svg)

```
[![Health](https://phpackages.com/badges/asif-laravel-model-logs/health.svg)](https://phpackages.com/packages/asif-laravel-model-logs)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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