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

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

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.

4.0.0(3mo ago)7551.9M↓34.6%69[2 issues](https://github.com/mattiverse/Laravel-Userstamps/issues)14MITPHPPHP ^8.2CI failing

Since Mar 10Pushed 3mo ago13 watchersCompare

[ Source](https://github.com/mattiverse/Laravel-Userstamps)[ Packagist](https://packagist.org/packages/wildside/userstamps)[ RSS](/packages/wildside-userstamps/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (10)Versions (34)Used By (14)

 [![](./logo.svg)](./logo.svg)

[![Total Downloads](https://camo.githubusercontent.com/181b9a32b64509ad0e7e8a5d5fe4ab3403ac9ab7593fb3ae9c2ca02fc8ced0c1/68747470733a2f2f706f7365722e707567782e6f72672f77696c64736964652f757365727374616d70732f646f776e6c6f616473)](https://packagist.org/packages/wildside/userstamps)[![Latest Stable Version](https://camo.githubusercontent.com/9dcca90a318c95fdeed6f584863aaf94d96420645c929146aa81c80bf5f52219/68747470733a2f2f706f7365722e707567782e6f72672f77696c64736964652f757365727374616d70732f76)](https://packagist.org/packages/wildside/userstamps)[![License](https://camo.githubusercontent.com/8abae2c9930f0a60acef785bddd765105fe091b883d69bfb69d2038beb978857/68747470733a2f2f706f7365722e707567782e6f72672f77696c64736964652f757365727374616d70732f6c6963656e7365)](https://packagist.org/packages/wildside/userstamps)

About Laravel Userstamps
------------------------

[](#about-laravel-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.

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

Installing
----------

[](#installing)

This package requires Laravel 9 or later running on PHP 8.2 or higher.

This package can be installed using composer:

```
composer require wildside/userstamps

```

Usage
-----

[](#usage)

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 column in your user's table.

Userstamp columns can be created using:

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

Equivalent methods are also available when working with UUIDs.

```
$table->userstampsUuid();
$table->userstampsUuidSoftDeletes();
```

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

```
use Mattiverse\Userstamps\Traits\Userstamps;

class Foo extends Model {

    use Userstamps;
}
```

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.

```
use Mattiverse\Userstamps\Traits\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';
}
```

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
```

Resolving Users
---------------

[](#resolving-users)

By default users will be resolved using the Laravel `Auth::id()` method, to return the ID of the currently authenticated user.

More advanced use-cases are supported with a custom resolution strategy.

In this example, a custom resolution method is called to retrieve the ID.

```
use Mattiverse\Userstamps\Userstamps;

Userstamps::resolveUsing(
    fn () => auth()->user()->customUserIdResolutionMethod()
);
```

The `Userstamps::resolveUsing` method is likely best suited to the `boot` method of `AppServiceProvider`.

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

[](#workarounds)

This package works 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',
]);
```

License
-------

[](#license)

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

###  Health Score

71

—

ExcellentBetter than 100% of packages

Maintenance80

Actively maintained with recent releases

Popularity64

Solid adoption and visibility

Community37

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 58.6% 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 ~114 days

Recently: every ~97 days

Total

33

Last Release

106d ago

Major Versions

0.6.0 → 1.0.0-rc.02019-09-20

1.2.0 → 2.0.02020-03-09

2.x-dev → 3.0.02025-02-22

3.1.1 → 4.0.02026-03-19

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

0.1.2PHP &gt;=5.5.9

3.0.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![mattmcdev](https://avatars.githubusercontent.com/u/1255436?v=4)](https://github.com/mattmcdev "mattmcdev (17 commits)")[![tkayfun](https://avatars.githubusercontent.com/u/10990971?v=4)](https://github.com/tkayfun "tkayfun (2 commits)")[![inmanturbo](https://avatars.githubusercontent.com/u/47095624?v=4)](https://github.com/inmanturbo "inmanturbo (1 commits)")[![JustinByrne](https://avatars.githubusercontent.com/u/14056930?v=4)](https://github.com/JustinByrne "JustinByrne (1 commits)")[![mahmoudmohamedramadan](https://avatars.githubusercontent.com/u/48416569?v=4)](https://github.com/mahmoudmohamedramadan "mahmoudmohamedramadan (1 commits)")[![geisi](https://avatars.githubusercontent.com/u/10728579?v=4)](https://github.com/geisi "geisi (1 commits)")[![RomeroMsk](https://avatars.githubusercontent.com/u/4639951?v=4)](https://github.com/RomeroMsk "RomeroMsk (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")[![Suh-Edmond](https://avatars.githubusercontent.com/u/55605309?v=4)](https://github.com/Suh-Edmond "Suh-Edmond (1 commits)")[![tacone](https://avatars.githubusercontent.com/u/659801?v=4)](https://github.com/tacone "tacone (1 commits)")[![mazyvan](https://avatars.githubusercontent.com/u/10915753?v=4)](https://github.com/mazyvan "mazyvan (1 commits)")[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (1 commits)")

---

Tags

laravellaravel-packagephptraituserstampslaraveleloquentuserstampscreated\_byupdated\_bydeleted\_by

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.4M96](/packages/mongodb-laravel-mongodb)[lemaur/eloquent-publishing

218.1k1](/packages/lemaur-eloquent-publishing)

PHPackages © 2026

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