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

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

sansanlabs/laravel-userstamps
=============================

Package to add userstamps to models.

v7.0.0(2mo ago)2763[1 PRs](https://github.com/sansanlabs/laravel-userstamps/pulls)2MITPHPPHP ^8.3CI passing

Since Apr 21Pushed 2mo agoCompare

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

READMEChangelog (10)Dependencies (26)Versions (11)Used By (2)

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

[](#laravel-userstamps)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b6ebdfbb916ab157f0c17b6d6c75b0e6693fa249f4956c120958f3bed5d065f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73616e73616e6c6162732f6c61726176656c2d757365727374616d70732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sansanlabs/laravel-userstamps)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8e332870fe3beccbc6101e1385385e2d12ea7d4583faf70fbb7c2caee68bbc87/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73616e73616e6c6162732f6c61726176656c2d757365727374616d70732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/sansanlabs/laravel-userstamps/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/a8951a181a037516ef17fcf704cfadb3bfe6149fa6e076a64cd0fc23324b284d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73616e73616e6c6162732f6c61726176656c2d757365727374616d70732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/sansanlabs/laravel-userstamps/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/006e13400b9106297180a027137411918c53f4935b45b632191cb50e97dafc92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73616e73616e6c6162732f6c61726176656c2d757365727374616d70732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sansanlabs/laravel-userstamps)

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

[](#installation)

You can install the package via composer:

```
composer require sansanlabs/laravel-userstamps
```

You can publish the config file with:

```
php artisan vendor:publish --tag="userstamps-config"
```

This is the contents of the published config file:

```
return [
    /*
    | If set to true, the package will generate polymorphic relations
    | with an additional "_type" column.
    |
    | ⚠️ Warning:
    | Please make sure to enable or disable this BEFORE running migrations,
    | as it affects how your relationship columns are generated.
    |
    */
    'is_using_morph' => false,

    /*
    | The name of the table that holds the users.
    |
    | ⚠️ Note:
    | This configuration is used **only when "is_using_morph" is false**.
    | If "is_using_morph" is set to true, this value will be ignored
    | because the relationship will use polymorphic "_type" columns instead
    | of a fixed user table reference.
    |
    */
    'users_table' => 'users',

    /*
    | The model that holds the users.
    |
    | ⚠️ Note:
    | This configuration is used **only when "is_using_morph" is false**.
    | If "is_using_morph" is set to true, this value will be ignored
    | because the morph relationship dynamically references the related model
    | based on the stored "_type" column.
    |
    */
    'users_model' => \App\Models\User::class,

    /*
    | Specify the column type used in the schema for the account ID
    |
    | Options: increments, bigIncrements, uuid, ulid
    | Default: bigIncrements
    |
    */
    'users_table_id_column_type' => 'bigIncrements',

    /*
    | Specify the column name used as the foreign key reference for the account ID.
    | Make sure all user tables have an ID column name that matches the one you define below.
    |
    */
    'users_table_id_column_name' => 'id',

    /*
    | If you set the column name to "created_by",
    | it will generate two columns:
    | - created_by_id
    | - created_by_type (if morph is enabled)
    */
    'created_by_column' => 'created_by',

    /*
    | If you set the column name to "updated_by",
    | it will generate two columns:
    | - updated_by_id
    | - updated_by_type (if morph is enabled)
    |
    */
    'updated_by_column' => 'updated_by',

    /*
    | If you set the column name to "deleted_by",
    | it will generate two columns:
    | - deleted_by_id
    | - deleted_by_type (if morph is enabled)
    |
    */
    'deleted_by_column' => 'deleted_by',

    /*
    | Indicate whether to include soft-deleted records in queries
    |
    */
    'with_trashed' => false,
];
```

Usage
-----

[](#usage)

Add the macro to your migration of your model

```
public function up(){
    Schema::create('table_name', function (Blueprint $table) {
        ...
        $table->userstamps();
        $table->softUserstamps();
    });
}
```

Add the macro to your existing table

```
public function up()
{
    Schema::table('table_name', function($table) {
        ...
        $table->userstamps();
        $table->softUserstamps();
    });
}

public function down()
{
    Schema::table('table_name', function($table) {
        $table->dropUserstamps();
        $table->dropSoftUserstamps();
    });
}
```

Add the Trait to your model

```
use SanSanLabs\UserStamps\Concerns\HasUserstamps;

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

There will be methods available to retrieve the user object which performs the action for creating, updating or deleting

```
$model->createdBy; // the user who created the model
$model->updatedBy; // the user who last updated the model
$model->deletedBy; // the user who deleted the model
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Edi Kurniawan](https://github.com/edikurniawan-dev)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance87

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.3% 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 ~36 days

Total

10

Last Release

64d ago

Major Versions

v1.0.0 → v4.0.02025-04-21

v4.2.0 → v5.0.02025-09-06

v5.0.0 → v6.0.02025-11-05

v6.2.1 → v7.0.02026-03-16

PHP version history (3 changes)v1.0.0PHP ^8.4

v4.2.0PHP ^8.2

v5.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/4debb9533a0ca6688ded80d730a8e978a103b90bf0c5c22c59fa106eb92711c4?d=identicon)[sansanlabs](/maintainers/sansanlabs)

---

Top Contributors

[![edikurniawan-dev](https://avatars.githubusercontent.com/u/50087198?v=4)](https://github.com/edikurniawan-dev "edikurniawan-dev (63 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

creatordestroyereditorlaraveluserstampslaraveleloquentuserstampscreated\_byupdated\_bydeleted\_bymodel events

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/sansanlabs-laravel-userstamps/health.svg)](https://phpackages.com/packages/sansanlabs-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)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[giacomomasseron/laravel-models-generator

Generate Laravel models from an existing database

484.2k](/packages/giacomomasseron-laravel-models-generator)

PHPackages © 2026

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