PHPackages                             dalisoft/userstamps - 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. dalisoft/userstamps

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

dalisoft/userstamps
===================

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

3.0.1(1y ago)033MITPHPPHP &gt;=7.2

Since Mar 10Pushed 1y agoCompare

[ Source](https://github.com/DanielKimmich/Laravel-Userstamps)[ Packagist](https://packagist.org/packages/dalisoft/userstamps)[ RSS](/packages/dalisoft-userstamps/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (4)Versions (35)Used By (0)

Laravel Userstamps
==================

[](#laravel-userstamps)

 [ ![Latest Stable Version](https://camo.githubusercontent.com/064f2b3aa9d3c520802a516bc73bb07e315a28a6d59559d7b8aa4bea72df1721/68747470733a2f2f706f7365722e707567782e6f72672f64616c69736f66742f757365727374616d70732f762f737461626c652e737667) ](https://packagist.org/packages/dalisoft/userstamps) [ ![License](https://camo.githubusercontent.com/e837c75317747115537680840e3177aa5c66f9c9a3adae2bb3eda4134e45188d/68747470733a2f2f706f7365722e707567782e6f72672f64616c69736f66742f757365727374616d70732f6c6963656e73652e737667) ](https://packagist.org/packages/dalisoft/userstamps) [ ![Total Downloads](https://camo.githubusercontent.com/7477833f7779f4e119a0c764e5f8192f54e5d98ac3920c3a435d6778ad36a518/68747470733a2f2f706f7365722e707567782e6f72672f64616c69736f66742f757365727374616d70732f642f746f74616c2e737667) ](https://packagist.org/packages/dalisoft/userstamps)

About
-----

[](#about)

Laravel Userstamps is a Laravel package for your Eloquent Model users fields: `created_by`, `updated_by` and `deleted_by`. This package automatically inserts/updates an user id on your table on who created, last updated and deleted the record.

When using the Laravel `SoftDeletes` trait, a `deleted_by` colummn is also handled by this package.

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

[](#installation)

This package requires Laravel 5.2 or later running on PHP 5.6 or higher.

This package can be installed using composer:

```
composer require dalisoft/userstamps

```

Configuration
-------------

[](#configuration)

Register the ServiceProvider in your config/app.php service provider list.

config/app.php

```
return [
    //other
    'providers' => [
        //other
        DaLiSoft\Userstamps\UserStampServiceProvider::class,
    ];
];

```

Usage
-----

[](#usage)

### On Migrations

[](#on-migrations)

Your model will need to include a `created_by` and `updated_by` column, defaulting to `null`. If using the Laravel `SoftDeletes` trait, it will also need a `deleted_by` column.

The column type should match the type of the ID colummn in your user's table. In Laravel &lt;= 5.7 this defaults to `unsignedInteger`. For Laravel &gt;= 5.8 this defaults to `unsignedBigInteger`.

You can use the Blueprint method `userstamps()` and add created\_by, updated\_by and deleted\_by.

An example migration with Blueprint method:

```
Schema::create('mytable', function (Blueprint $table) {

    $table->userstamps();
});
```

An example migration add user stamp field:

```
Schema::create('mytable', function (Blueprint $table) {

    $table->unsignedInteger('created_by')->nullable();
    $table->unsignedInteger('updated_by')->nullable();
    $table->unsignedInteger('deleted_by')->nullable();
});
```

An example migration drop auditable columns:

```
Schema::create('mytable', function (Blueprint $table) {

    $table->dropUserstamps();
});
```

### Attaching to Model

[](#attaching-to-model)

You can now load the trait within your model, and userstamps will automatically be maintained:

```
use DaLiSoft\Userstamps\Userstamps;

class Foo extends Model {

    use Userstamps;
}
```

### custom attributes

[](#custom-attributes)

Optionally, should you wish to override the names of the `created_by`, `updated_by` or `deleted_by` columns, you can do so by setting the appropriate class constants on your model. Ensure you match these column names in your migration. You can also set the name of the `display_user` column that you want to return in the methods, by default it returns name.

```
use DaLiSoft\Userstamps\Userstamps;

class Foo extends Model {

    use Userstamps;
    const CREATED_BY = 'alt_created_by';
    const UPDATED_BY = 'alt_updated_by';
    const DELETED_BY = 'alt_deleted_by';
    const DISPLAY_USER = 'email';
}
```

When using this trait, helper relationships are available to let you retrieve the user who created, updated and deleted (when using the Laravel `SoftDeletes` trait) your model.

```
$model->creator; // the user who created the model
$model->editor; // the user who last updated the model
$model->destroyer; // the user who deleted the model
```

Methods are also available to temporarily stop the automatic maintaining of userstamps on your models:

```
$model->stopUserstamping(); // stops userstamps being maintained on the model
$model->startUserstamping(); // resumes userstamps being maintained on the model
```

There are also attributes available to get the name / mail / ... of the creator, editor and destroyer user in their models:

```
$model->created_by_user; // creator username in the model
$model->updated_by_user; // editor username in the model
$model->deleted_by_user; // destroyer username in the model
```

Workarounds
-----------

[](#workarounds)

This package works by by hooking into Eloquent's model event listeners, and is subject to the same limitations of all such listeners.

When you make changes to models that bypass Eloquent, the event listeners won't be fired and userstamps will not be updated.

Commonly this will happen if bulk updating or deleting models, or their relations.

In this example, model relations are updated via Eloquent and userstamps **will** be maintained:

```
$model->foos->each(function ($item) {
    $item->bar = 'x';
    $item->save();
});
```

However in this example, model relations are bulk updated and bypass Eloquent. Userstamps **will not** be maintained:

```
$model->foos()->update([
    'bar' => 'x',
]);
```

As a workaroud to this issue two helper methods are available - `updateWithUserstamps` and `deleteWithUserstamps`. Their behaviour is identical to `update` and `delete`, but they ensure the `updated_by` and `deleted_by` properties are maintained on the model.

You generally won't have to use these methods, unless making bulk updates that bypass Eloquent events.

In this example, models are bulk updated and userstamps **will not** be maintained:

```
$model->where('name', 'foo')->update([
    'name' => 'bar',
]);
```

However in this example, models are bulk updated using the helper method and userstamps **will** be maintained:

```
$model->where('name', 'foo')->updateWithUserstamps([
    'name' => 'bar',
]);
```

References
----------

[](#references)

This project was developed using the [WILDSIDE](https://github.com/WildsideUK/Laravel-Userstamps) project.

I have added new qualities to the package, such as getting the name or email of the user who created, updated and unregistered.

The functionality was also added to update the user in a parent table when creating, modifying, or deleting a record in the child table.

License
-------

[](#license)

This open-source software is licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 82.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 ~95 days

Recently: every ~284 days

Total

34

Last Release

572d ago

Major Versions

0.6.0 → 1.0.0-rc.02019-09-20

1.2.0 → 2.0.02020-03-09

2.2.6 → 3.0.12024-10-22

PHP version history (3 changes)0.1.0PHP &gt;=5.6

0.1.2PHP &gt;=5.5.9

3.0.1PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/e52d354806663f7a0bfc00c7448f40413f96d39d20d46a22aed89ad115f59b35?d=identicon)[Daniel Kimmich](/maintainers/Daniel%20Kimmich)

---

Top Contributors

[![DanielKimmich](https://avatars.githubusercontent.com/u/44840413?v=4)](https://github.com/DanielKimmich "DanielKimmich (23 commits)")[![tkayfun](https://avatars.githubusercontent.com/u/10990971?v=4)](https://github.com/tkayfun "tkayfun (2 commits)")[![mazyvan](https://avatars.githubusercontent.com/u/10915753?v=4)](https://github.com/mazyvan "mazyvan (1 commits)")[![RomeroMsk](https://avatars.githubusercontent.com/u/4639951?v=4)](https://github.com/RomeroMsk "RomeroMsk (1 commits)")[![tacone](https://avatars.githubusercontent.com/u/659801?v=4)](https://github.com/tacone "tacone (1 commits)")

---

Tags

laraveleloquentuserstampscreated\_byupdated\_bydeleted\_by

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dalisoft-userstamps/health.svg)

```
[![Health](https://phpackages.com/badges/dalisoft-userstamps/health.svg)](https://phpackages.com/packages/dalisoft-userstamps)
```

###  Alternatives

[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

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