PHPackages                             insenseanalytics/laravel-user-audit-trails - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. insenseanalytics/laravel-user-audit-trails

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

insenseanalytics/laravel-user-audit-trails
==========================================

User audit trails for Laravel Eloquent.

v2.0(5y ago)254082MITPHPCI failing

Since Aug 18Pushed 5y ago1 watchersCompare

[ Source](https://github.com/insenseanalytics/laravel-user-audit-trails)[ Packagist](https://packagist.org/packages/insenseanalytics/laravel-user-audit-trails)[ RSS](/packages/insenseanalytics-laravel-user-audit-trails/feed)WikiDiscussions master Synced 3w ago

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

Laravel User Audit Trails
=========================

[](#laravel-user-audit-trails)

[![tests](https://github.com/insenseanalytics/laravel-user-audit-trails/workflows/tests/badge.svg?branch=master)](https://github.com/insenseanalytics/laravel-user-audit-trails/workflows/tests/badge.svg?branch=master)[![License](https://camo.githubusercontent.com/7d27ef63d6075a826d5836dc8b3e2d3ae7cdcfddd9581b137c42d0da96e3cdbe/68747470733a2f2f706f7365722e707567782e6f72672f696e73656e7365616e616c79746963732f6c61726176656c2d757365722d61756469742d747261696c732f6c6963656e7365)](https://packagist.org/packages/insenseanalytics/laravel-user-audit-trails)[![Latest Stable Version](https://camo.githubusercontent.com/8caf0f70ef73c39a481aaeaf0b3da8b2c2dde8406694eaa3f3eee22e49022fcd/68747470733a2f2f706f7365722e707567782e6f72672f696e73656e7365616e616c79746963732f6c61726176656c2d757365722d61756469742d747261696c732f762f737461626c65)](https://packagist.org/packages/insenseanalytics/laravel-user-audit-trails)[![Total Downloads](https://camo.githubusercontent.com/54314c47139e5c07f19ddec0ca4e468cb917893ae27580d718c25ec3c78cd3fa/68747470733a2f2f706f7365722e707567782e6f72672f696e73656e7365616e616c79746963732f6c61726176656c2d757365722d61756469742d747261696c732f646f776e6c6f616473)](https://packagist.org/packages/insenseanalytics/laravel-user-audit-trails)

This package is created to add audit user trails by using Laravel Eloquent ORM. Using this package, you would be able to record in the respective database tables, the `created_by`, `updated_by` and `deleted_by` user IDs.

Basic Example
-------------

[](#basic-example)

Add the audit trail columns in your database **migrations** like so:

```
$table->usertrails(); // for created_by, updated_by
$table->deletetrails(); // for deleted_by
```

Next, in your model just use the `HasUserTrails` and `HasDeleteTrails` trait to automatically setup audit user trails like so:

```
class Post extends \Illuminate\Database\Eloquent\Model
{
    use \Insense\LaravelUserAuditTrails\HasUserTrails;
    use \Insense\LaravelUserAuditTrails\HasDeleteTrails;
}
```

That's it! Now, sit back and observe the magic of audit user trails. When a new record is created, `created_by` will be updated to the user ID that created it. When a record is updated, `updated_by` will be updated to the user ID that updated it. When a record is soft deleted, `deleted_by` will be updated to the user ID that deleted it.

Requirements
------------

[](#requirements)

- [PHP &gt;= 7.1](http://php.net/)
- [Laravel 5.5+|6.x|7.x|8.x](https://github.com/laravel/framework)

Quick Installation
------------------

[](#quick-installation)

```
$ composer require insenseanalytics/laravel-user-audit-trails
```

#### Service Provider (Optional / auto discovered on Laravel 5.5+)

[](#service-provider-optional--auto-discovered-on-laravel-55)

Register provider on your `config/app.php` file.

```
'providers' => [
    ...,
    Insense\LaravelUserAuditTrails\UserTrailsServiceProvider::class,
]
```

Setting Up Custom Column Names
------------------------------

[](#setting-up-custom-column-names)

If you want to override the default audit trail names of `created_by`, `updated_by` and `deleted_by`, you may do so like so:

In your database **migration**, add the audit trail columns like so:

```
$table->usertrails('your-created-by-column', 'your-updated-by-column');
$table->deletetrails('your-deleted-by-column');
```

Next, in your model, override the static properties `CREATED_BY`, `UPDATED_BY` and `DELETED_BY`. Note that PHP does not allow overriding static properties in the same class, so you would need to extend your model class from a base model class that uses the `\Insense\LaravelUserAuditTrails\HasUserTrails` trait like so:

First create your base model class (if not already created). If already created, just add the trait.

```
class BaseModel extends \Illuminate\Database\Eloquent\Model
{
    use \Insense\LaravelUserAuditTrails\HasUserTrails;
    use \Insense\LaravelUserAuditTrails\HasDeleteTrails;
}
```

Next, override the static properties `CREATED_BY`, `UPDATED_BY` and `DELETED_BY` in your model (that extends the base model) like so:

```
class YourModel extends BaseModel
{
    public static $CREATED_BY = 'your-created-by-column';
    public static $UPDATED_BY = 'your-updated-by-column';
    public static $DELETED_BY = 'your-deleted-by-column';
}
```

Omitting Updated By or Created By Columns
-----------------------------------------

[](#omitting-updated-by-or-created-by-columns)

If you wish to omit one of the audit trail columns, you can just set the one you would like to omit to null in your database **migration** like so:

```
$table->usertrails('created_by', null);
```

The example above omits the updated\_by column. You can also do the reverse to omit updated\_by by setting the first argument to null.

Next, override the static properties `CREATED_BY` and `UPDATED_BY` in your model (that extends the base model) to set the omitted property to null like so:

```
class YourModel extends BaseModel
{
    public static $CREATED_BY = 'created_by';
    public static $UPDATED_BY = null;
}
```

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

[](#contributing)

We are open to PRs as long as they're backed by tests and a small description of the feature added / problem solved.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/insenseanalytics/laravel-user-audit-trails/blob/master/LICENSE.txt) for more information.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 82.9% 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 ~255 days

Total

4

Last Release

2103d ago

Major Versions

v1.0.2 → v2.02020-09-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3b4395cbe0ac91e6c75a298f834f347905a340bd030e5f2046249a341569fee?d=identicon)[paras-malhotra](/maintainers/paras-malhotra)

---

Top Contributors

[![paras-malhotra](https://avatars.githubusercontent.com/u/16099046?v=4)](https://github.com/paras-malhotra "paras-malhotra (29 commits)")[![amit-insense](https://avatars.githubusercontent.com/u/42092723?v=4)](https://github.com/amit-insense "amit-insense (6 commits)")

---

Tags

auditaudit-logsaudit-traillaravellaravelAuditaudit\_trailsuser trails

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/insenseanalytics-laravel-user-audit-trails/health.svg)

```
[![Health](https://phpackages.com/badges/insenseanalytics-laravel-user-audit-trails/health.svg)](https://phpackages.com/packages/insenseanalytics-laravel-user-audit-trails)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[wearepixel/laravel-cart

A cart implementation for Laravel

1355.6k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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