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

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

danielemontecchi/laravel-userstamps
===================================

Automatically track the user who created, updated, or deleted Eloquent models in Laravel, with database macros and model traits.

v1.1.0(1mo ago)127MITPHPPHP ^8.2CI passing

Since May 8Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/danielemontecchi/laravel-userstamps)[ Packagist](https://packagist.org/packages/danielemontecchi/laravel-userstamps)[ Docs](https://danielemontecchi.com)[ RSS](/packages/danielemontecchi-laravel-userstamps/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (8)Versions (3)Used By (0)

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

[](#laravel-userstamps)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4c3209f6f6ae0a4c859ebb760e6c7661442f59e0b856da5f4b101e2aaa91eab0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64616e69656c656d6f6e7465636368692f6c61726176656c2d757365727374616d70732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielemontecchi/laravel-userstamps)[![Total Downloads](https://camo.githubusercontent.com/5fafa95a1fe993ee38071b03e68ff7f4c212215d223cc5bc56d1a513b5a7915c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64616e69656c656d6f6e7465636368692f6c61726176656c2d757365727374616d70732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/danielemontecchi/laravel-userstamps)[![License: MIT](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![GitHub Tests Action Status](https://camo.githubusercontent.com/e10b724e88e7540227a17ea27399e02e7e90a765f737a660e4ff40f35f67374a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64616e69656c656d6f6e7465636368692f6c61726176656c2d757365727374616d70732f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/danielemontecchi/laravel-userstamps/actions/workflows/tests.yml)[![Coverage](https://camo.githubusercontent.com/09fdf8b75b33b7b9a7a8e2423aeb2144b97e969f16b186241a3082a3251c285b/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d64616e69656c656d6f6e7465636368695f6c61726176656c2d757365727374616d7073266d65747269633d636f766572616765)](https://sonarcloud.io/summary/new_code?id=danielemontecchi_laravel-userstamps)[![PHPStan](https://camo.githubusercontent.com/cfad767368c5b88c30d3a7087a14099cb45895b5ded11e2ae54aa298b7ba5893/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![Quality Gate Status](https://camo.githubusercontent.com/a3a4b69e4629eb98f952c7376a39b7b710f74f8fd34a1cc62482fd7125cc885b/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d64616e69656c656d6f6e7465636368695f6c61726176656c2d757365727374616d7073266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/summary/new_code?id=danielemontecchi_laravel-userstamps)[![Maintainability Rating](https://camo.githubusercontent.com/7b7e4b44a3f8ef140f21534b7bef60f1cf9aeeef99ae3cad3742d8f841228c64/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d64616e69656c656d6f6e7465636368695f6c61726176656c2d757365727374616d7073266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/summary/new_code?id=danielemontecchi_laravel-userstamps)[![Documentation](https://camo.githubusercontent.com/09e816ae34b01c0a0c356178a99f4041e3c82696002ef2dd521eb5b0f16c6ace/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d617661696c61626c652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://danielemontecchi.github.io/laravel-userstamps)

**Laravel Userstamps** is a lightweight, plug-and-play package to automatically track the user who created, updated, or deleted an Eloquent model in Laravel.

Much like Laravel's `timestamps()` for `created_at` and `updated_at`, this package handles the `created_by`, `updated_by`, and `deleted_by` fields in a clean and consistent way.

---

🛠️ Installation
---------------

[](#️-installation)

```
composer require danielemontecchi/laravel-userstamps
```

Laravel automatically registers the service provider via package discovery.

---

⚙️ Usage in Eloquent models
---------------------------

[](#️-usage-in-eloquent-models)

Add the `HasUserstamps` trait to any model where you want userstamps to be tracked:

```
use DanieleMontecchi\LaravelUserstamps\Traits\HasUserstamps;

class Post extends Model
{
    use HasUserstamps;
}
```

The trait automatically listens to Eloquent model events (`creating`, `updating`, `deleting`, `restoring`) and fills the appropriate `*_by` fields **only if they exist** in the database.

---

🧱 Migration helpers
-------------------

[](#-migration-helpers)

The package provides expressive migration macros:

### ➕ Add `created_by` and `updated_by`

[](#-add-created_by-and-updated_by)

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

### ➕ Add `deleted_by` (similar to `softDeletes()`)

[](#-add-deleted_by-similar-to-softdeletes)

```
$table->softDeletesBy();
```

### 🧩 Full example

[](#-full-example)

```
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');

    $table->userstamps();       // created_by, updated_by
    $table->timestamps();       // created_at, updated_at
    $table->softDeletes();      // deleted_at
    $table->softDeletesBy();    // deleted_by
});
```

---

👤 User relations
----------------

[](#-user-relations)

The trait adds inverse relationships to the `User` model (or whatever model uses the IDs):

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

---

🚫 Temporarily disable tracking
------------------------------

[](#-temporarily-disable-tracking)

You can disable userstamping (e.g. during seeding, bulk import, or testing):

```
Post::disableUserstamps();

Post::create(['title' => 'Imported without tracking']);

Post::enableUserstamps();
```

---

🔧 Requirements
--------------

[](#-requirements)

- PHP 8.1+
- Laravel 10.x, 11.x, 12.x, 13.x
- A `users` table (or any custom user model)

> Note: field names are not hardcoded. The macros can be customized or replaced as needed.

---

✅ Why this package?
-------------------

[](#-why-this-package)

- ✔️ Laravel-like API: `userstamps()` and `softDeletesBy()`
- ✔️ Zero configuration
- ✔️ Only acts on existing columns
- ✔️ Soft delete &amp; restore support
- ✔️ Great for audits, logs, traceability

---

License
-------

[](#license)

Laravel Userstamps is open-source software licensed under the **MIT license**. See the [LICENSE.md](LICENSE.md) file for full details.

---

Made with ❤️ by [Daniele Montecchi](https://danielemontecchi.com)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Every ~323 days

Total

2

Last Release

46d ago

PHP version history (2 changes)v1.0.0PHP ^8.1 || ^8.2 || ^8.3 || ^8.4

v1.1.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/8893e23896e96d0984bc8803307baa52fd63e7e2c08c4048d90a95023f134864?d=identicon)[danielemontecchi](/maintainers/danielemontecchi)

---

Top Contributors

[![danielemontecchi](https://avatars.githubusercontent.com/u/2247871?v=4)](https://github.com/danielemontecchi "danielemontecchi (13 commits)")

---

Tags

auditauthenticationblameablecreated-bydeleted-byeloquentlaravellaravel-packagemodel-eventstimestampsupdated-byuserstampslaraveleloquentlaravel-packageBlameableAudituserstampscreated\_byupdated\_bydeleted\_bymodel events

###  Code Quality

TestsPest

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/danielemontecchi-laravel-userstamps/health.svg)](https://phpackages.com/packages/danielemontecchi-laravel-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)[richan-fongdasen/eloquent-blameable

Blameable behavior implementation for your Eloquent Model in Laravel

34213.1k3](/packages/richan-fongdasen-eloquent-blameable)

PHPackages © 2026

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