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

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

turahe/laravel-userstamps
=========================

Adds user tracking fields to Laravel models.

1.2.1(8mo ago)0284[3 PRs](https://github.com/turahe/laravel-userstamps/pulls)2MITPHPPHP ^8.2CI passing

Since Sep 10Pushed 4mo ago1 watchersCompare

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

READMEChangelog (3)Dependencies (3)Versions (11)Used By (2)

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

[](#laravel-userstamps)

[![CI](https://github.com/turahe/laravel-userstamps/actions/workflows/php.yml/badge.svg)](https://github.com/turahe/laravel-userstamps/actions/workflows/php.yml)[![Security](https://github.com/turahe/laravel-userstamps/actions/workflows/security.yml/badge.svg)](https://github.com/turahe/laravel-userstamps/actions/workflows/security.yml)[![codecov](https://camo.githubusercontent.com/e4dfe4c87eeda3d2b1bb2b6933484735bd97cc2a25c2012df1c7da07f14d5dd6/68747470733a2f2f636f6465636f762e696f2f67682f7475726168652f6c61726176656c2d757365727374616d70732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/turahe/laravel-userstamps)[![Latest Stable Version](https://camo.githubusercontent.com/39eceba26f2923386e92f019a0be7fd57cdbee10771ed75b9ee433a5c132eb71/68747470733a2f2f706f7365722e707567782e6f72672f7475726168652f6c61726176656c2d757365727374616d70732f762f737461626c65)](https://packagist.org/packages/turahe/laravel-userstamps)[![Total Downloads](https://camo.githubusercontent.com/df79860aaabd2e61b117e95758e908baa0a83dcef73eca329383c8f408d8f9b6/68747470733a2f2f706f7365722e707567782e6f72672f7475726168652f6c61726176656c2d757365727374616d70732f646f776e6c6f616473)](https://packagist.org/packages/turahe/laravel-userstamps)[![Monthly Downloads](https://camo.githubusercontent.com/bd88d09d6f8629843d55bcf0b3fc59a9ea7463ae1e4651d7906f3b38f995eb22/68747470733a2f2f706f7365722e707567782e6f72672f7475726168652f6c61726176656c2d757365727374616d70732f642f6d6f6e74686c79)](https://packagist.org/packages/turahe/laravel-userstamps)[![Daily Downloads](https://camo.githubusercontent.com/e791bf340c331b05119ca8668fe0a0ea5142141e153cf17cc2875c9277b87e19/68747470733a2f2f706f7365722e707567782e6f72672f7475726168652f6c61726176656c2d757365727374616d70732f642f6461696c79)](https://packagist.org/packages/turahe/laravel-userstamps)[![License](https://camo.githubusercontent.com/957a4ec0cc3759f47f2d7ebf8787066672987a4c24365a49c1c3da89412b0742/68747470733a2f2f706f7365722e707567782e6f72672f7475726168652f6c61726176656c2d757365727374616d70732f6c6963656e7365)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/744f8821cc27dec8b0013ade48179731a44eadf4f943e0b1d9ffcb93f80177de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322532422d626c75652e737667)](https://php.net)[![Laravel Version](https://camo.githubusercontent.com/a2f0d069397ac2086eb8685dcd1ea8e22d9de76a932bc62aacfb136a76a7a243/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3130253242253230253743253230313125324225323025374325323031322532422d7265642e737667)](https://laravel.com)[![StyleCI](https://camo.githubusercontent.com/8c821155625e502b838f49895dcde6b368b23635d33814a78c4fdcd82ceb309a/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f4348414e47454d452f6261646765)](https://styleci.io/repos/CHANGEME)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c85af97fd23f5ed85935e84484dc1cefcc25a88248c3052490c689c0e02b1717/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7475726168652f6c61726176656c2d757365727374616d70732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/turahe/laravel-userstamps/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/db4794b00931ab7918ffcb9f342b98c69b7c0f7296ca7479964e930bcff2d8d4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7475726168652f6c61726176656c2d757365727374616d70732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/turahe/laravel-userstamps/?branch=master)[![Build Status](https://camo.githubusercontent.com/de2378bdf1bd78eb8c5304b0fbd88ac5e70cab40d436ed37e860f0432a646ba5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7475726168652f6c61726176656c2d757365727374616d70732f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/turahe/laravel-userstamps/build-status/master)[![Dependabot Status](https://camo.githubusercontent.com/6502f4a3b4f3b9a0d7280a7351d553e8152d553f35932291e6867b730dab213b/68747470733a2f2f6170692e646570656e6461626f742e636f6d2f6261646765732f7374617475733f686f73743d676974687562267265706f3d7475726168652f6c61726176656c2d757365727374616d7073)](https://dependabot.com)[![Maintenance](https://camo.githubusercontent.com/5ca62441414bacaa54c6c6e5b68e46c76305947b6bf498c4949fc71c1b4b10dd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d61696e7461696e65642533462d7965732d677265656e2e737667)](https://github.com/turahe/laravel-userstamps/graphs/commit-activity)[![Made with Love](https://camo.githubusercontent.com/daf28183b75be68017827308f0f51d3dd67ebffa6983bc8e254abeb865e2e4c0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d616465253230776974682d4c6f76652d7265642e737667)](https://github.com/turahe/laravel-userstamps)

A Laravel package to automatically add `created_by`, `updated_by`, and `deleted_by` fields to your Eloquent models, with enhanced configuration options, custom column types, and comprehensive testing infrastructure.

---

Features
--------

[](#features)

- **Core Functionality**: Automatically tracks which user created, updated, or deleted a model
- **Enhanced Configuration**: Advanced options for customizing column types, names, and behavior
- **Custom UserStamps**: Support for custom column configurations and advanced use cases
- **Multi-Database Support**: Works with MySQL, PostgreSQL, and SQLite
- **Laravel Compatibility**: Supports Laravel 10, 11, and 12
- **Database Schema Macros**: Easy-to-use schema macros for userstamps
- **Comprehensive Testing**: GitHub Actions CI/CD with multi-database testing
- **Docker Integration**: Complete Docker setup for local development and testing
- **Code Quality**: Laravel Pint integration and security scanning

---

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

[](#installation)

```
composer require turahe/laravel-userstamps
```

---

Usage
-----

[](#usage)

### 1. Basic Usage with HasUserStamps

[](#1-basic-usage-with-hasuserstamps)

```
use Turahe\UserStamps\Concerns\HasUserStamps;

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

### 2. Advanced Usage with HasCustomUserStamps

[](#2-advanced-usage-with-hascustomuserstamps)

```
use Turahe\UserStamps\Concerns\HasCustomUserStamps;

class Post extends Model
{
    use HasCustomUserStamps;

    protected $userstampsConfig = [
        'columns' => [
            'created_by' => [
                'type' => 'uuid',
                'index' => true,
                'comment' => 'User who created this post'
            ],
            'updated_by' => [
                'type' => 'uuid',
                'nullable' => false
            ]
        ]
    ];
}
```

### 3. Database Schema

[](#3-database-schema)

Add the userstamps columns using the provided schema macros:

```
Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->string('title');
    $table->userstamps();      // Adds created_by and updated_by
    $table->softUserstamps();  // Adds deleted_by
    $table->timestamps();
    $table->softDeletes();
});
```

---

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

[](#configuration)

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --provider="Turahe\UserStamps\UserStampsServiceProvider" --tag="config"
```

### Enhanced Configuration Options

[](#enhanced-configuration-options)

The package now supports advanced configuration for customizing column behavior:

```
return [
    'users_table' => 'users',
    'users_table_column_type' => 'bigIncrements',
    'users_table_column_id_name' => 'id',
    'users_model' => env('AUTH_MODEL', 'App\User'),

    // Legacy column names (backward compatible)
    'created_by_column' => 'created_by',
    'updated_by_column' => 'updated_by',
    'deleted_by_column' => 'deleted_by',

    // Enhanced column configuration
    'columns' => [
        'created_by' => [
            'name' => 'created_by',
            'type' => null,                   // Auto-detect
            'nullable' => true,
            'index' => true,
            'foreign_key' => true,
            'on_delete' => 'set null',
            'comment' => 'User who created this record'
        ],
        'updated_by' => [
            'name' => 'updated_by',
            'type' => null,
            'nullable' => true,
            'index' => true,
            'foreign_key' => true,
            'on_delete' => 'set null',
            'comment' => 'User who last updated this record'
        ],
        'deleted_by' => [
            'name' => 'deleted_by',
            'type' => null,
            'nullable' => true,
            'index' => true,
            'foreign_key' => true,
            'on_delete' => 'set null',
            'comment' => 'User who deleted this record'
        ]
    ]
];
```

### Supported Column Types

[](#supported-column-types)

- `increments` - Auto-incrementing integer
- `bigIncrements` - Auto-incrementing big integer (default)
- `uuid` - UUID string
- `ulid` - ULID string
- `bigInteger` - Big integer
- `integer` - Regular integer
- `string` - Variable-length string
- `text` - Long text
- `char` - Fixed-length string

---

Testing
-------

[](#testing)

### Local Testing with Docker

[](#local-testing-with-docker)

**Requirements:** Docker, PHP 8.2+, Composer

```
# Start database containers
docker-compose up -d

# Run all tests (MySQL, PostgreSQL)
composer test:all

# Or test with a specific database
composer test:mysql
composer test:postgres
```

### Test Scripts

[](#test-scripts)

The package includes PowerShell and shell scripts for automated testing:

- **Windows**: `scripts/test-all.ps1`
- **Linux/macOS**: `scripts/test-all.sh`

### GitHub Actions CI/CD

[](#github-actions-cicd)

- Matrix tests for Laravel 12 and PHP 8.4
- Multi-database testing (MySQL and PostgreSQL)
- Code style checking with Laravel Pint
- Security scanning with Composer Audit and CodeQL

---

Documentation
-------------

[](#documentation)

For detailed information on advanced features:

- **[Enhanced Configuration](docs/ENHANCED_CONFIGURATION.md)** - Advanced configuration options and custom column types
- **[Docker Setup](docs/DOCKER_README.md)** - Complete Docker environment setup
- **[Docker Setup Summary](docs/DOCKER_SETUP_SUMMARY.md)** - Quick Docker setup guide

---

Docker Setup
------------

[](#docker-setup)

The package includes a complete Docker testing environment:

- **MySQL 8.0**: `127.0.0.1:3306`, user: `laravel_userstamps`, pass: `password`
- **PostgreSQL 15**: `127.0.0.1:5432`, user: `laravel_userstamps`, pass: `password`
- **Redis 7**: `127.0.0.1:6379`

See [DOCKER\_README.md](docs/DOCKER_README.md) for full setup instructions.

---

Security
--------

[](#security)

- Composer audit and CodeQL scanning in CI
- Dependabot for automated dependency updates
- Regular security vulnerability scanning

---

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

[](#contributing)

1. Fork the repo
2. Create your feature branch (`git checkout -b feature/foo`)
3. Commit your changes
4. Push to the branch (`git push origin feature/foo`)
5. Open a pull request

---

License
-------

[](#license)

MIT © [Nur Wachid](https://www.wach.id)

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance67

Regular maintenance activity

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

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 ~57 days

Recently: every ~42 days

Total

7

Last Release

269d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.0.1PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![turahe](https://avatars.githubusercontent.com/u/6832622?v=4)](https://github.com/turahe "turahe (26 commits)")

---

Tags

laraveluserstampsupdatedcreateddeleted

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[sqits/laravel-userstamps

Package to add created\_by, updated\_by and deleted\_by to models.

1837.3k](/packages/sqits-laravel-userstamps)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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