Laravel Packages

Who Changed That? Tracking User Modifications in Models with Userstamps

Published
Who Changed That? Tracking User Modifications in Models with Userstamps image

Laravel Userstamps is a package created by Matt McDonald which provides an Eloquent trait that automatically maintains created_by and updated_by columns on your model, populated by the currently authenticated user in your application.

Example

When defining your table migrations, you can use the userstamps() or userstampSoftDeletes() methods:

<?php
 
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
 
return new class extends Migration
{
public function up(): void
{
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->string('slug')->unique();
$table->boolean('published')->default(false);
 
// UserStamps columns
$table->userstamps();
// or $table->userstampSoftDeletes();
 
$table->timestamps();
});
}
};

A created_by, updated_by and deleted_by (if using SoftDeletes) columns will be added to your table.

You can now add the Userstamps trait to your model, and the user stamps will be automatically managed.

<?php
 
namespace App\Models;
 
use Illuminate\Database\Eloquent\Model;
use Mattiverse\Userstamps\Traits\Userstamps;
 
class Post extends Model
{
use Userstamps;
 
}

To install this package, use Composer:

composer require wildside/userstamps

Learn more and view the source code on GitHub.

Yannick Lyn Fatt photo

Staff Writer at Laravel News and Full stack web developer.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
Image Dominant Color and HEIC Support in Laravel 13.24 image

Image Dominant Color and HEIC Support in Laravel 13.24

Read article
Official Laravel Zed Extension: LSP for PHP & Blade image

Official Laravel Zed Extension: LSP for PHP & Blade

Read article
Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD image

Laravel Head: Manage Meta Tags, Open Graph, and JSON-LD

Read article
PhpStorm 2026.2 Released image

PhpStorm 2026.2 Released

Read article
Laravel Doctor: Diagnose Your App With One Artisan Command image

Laravel Doctor: Diagnose Your App With One Artisan Command

Read article
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article