PHPackages                             jlorente/laravel-identitystamps - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. jlorente/laravel-identitystamps

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

jlorente/laravel-identitystamps
===============================

A Laravel plugin to register and keep control of the users who make creations, updates and deletions of models

1.0.2(5y ago)16.0k↓40%BSD-3-ClausePHPPHP &gt;=7.0.0

Since Aug 15Pushed 5y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Laravel IdentityStamps Plugin
=============================

[](#laravel-identitystamps-plugin)

A Laravel plugin to register and keep control of users who make creations, updates and deletions of models.

With this plugin, you will manage automatically the control fields "created\_by", "updated\_by" and "deleted\_by" that will store the identity of the users that manipulate the models.

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

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

With Composer installed, you can then install the extension using the following commands:

```
$ php composer.phar require jlorente/laravel-identitystamps
```

or add

```
...
    "require": {
        "jlorente/laravel-identitystamps": "*"
    }
```

to the `require` section of your `composer.json` file.

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

[](#configuration)

Register the ServiceProvider in your config/app.php service provider list.

config/app.php

```
return [
    //other stuff
    'providers' => [
        //other stuff
        \Jlorente\Laravel\IdentityStamp\IdentityStampServiceProvider::class,
    ];
];
```

Usage
-----

[](#usage)

### On Migrations

[](#on-migrations)

You can use the Blueprint method identityStamps() to add nullable "created\_by" and "updated\_by" UNSIGNED INTEGER equivalent columns. Of course, you can create the columns by yourself with a custom name and type and then configure the Model class with these names, but remember that the type should be the same as the type of the key of your UserModel.

```
class MyMigration extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('my_table', function (Blueprint $table) {
            $table->increments('id');
            $table->string('my_field');
            $table->timestamps();
            $table->identityStamps();
        });
    }
}
```

If you use soft deletes, maybe you want to add an identity stamp for the deletion too. You can do this by using the softDeletesIdentityStamps() method that will add a nullable "deleted\_by" UNSIGNED INTEGER column.

```
class MyMigration extends Migration
{

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('products', function (Blueprint $table) {
            $table->increments('id');
            $table->string('my_field');
            $table->timestamps();
            $table->identityStamps();
            $table->softDeletes();
            $table->softDeletesIdentityStamps();
        });
    }
}
```

### Attaching the behavior to a Model

[](#attaching-the-behavior-to-a-model)

To enable identity stamps for a model, use the Jlorente\\IdentityStamp\\Eloquent\\IdentityStamps trait on the model:

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;

class Product extends Model
{
    use IdentityStamps,
        SoftDeletes;
}
```

Further considerations
----------------------

[](#further-considerations)

### Using custom attributes names

[](#using-custom-attributes-names)

You can use your custom attributes names to store the identity by defining class constants on the model.

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;

class Product extends Model
{
    use IdentityStamps,
        SoftDeletes;

    const CREATED_BY = 'my_custom_identity_creation_field';
    const UPDATED_BY = 'my_custom_identity_update_field';
    const DELETED_BY = 'my_custom_identity_deletion_field';
}
```

If you don't like class constants you can also override the trait methods that resolve the identity stamp fields.

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;

class Product extends Model
{
    use IdentityStamps,
        SoftDeletes;

    public function getCreatedByColumn()
    {
        return 'my_custom_identity_creation_field';
    }

    public function getUpdatedByColumn()
    {
        return 'my_custom_identity_update_field';
    }

    public function getDeletedByColumn()
    {
        return 'my_custom_identity_deletion_field';
    }
}
```

### Using custom identity id to be stored in the identity fields

[](#using-custom-identity-id-to-be-stored-in-the-identity-fields)

By default, the trait will use Laravel's Auth::id() method to retrieve the id that will be stored on the identity stamp fields. Feel free to override the method getIdentityStampValue() to return the value that you want to store in the fields.

```
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Auth;
use Jlorente\Laravel\IdentityStamp\Database\Eloquent\IdentityStamps;

class Product extends Model
{
    use IdentityStamps,
        SoftDeletes;

    public function getIdentityStampValue()
    {
        return Auth::user() ? Auth::user()->email : null;
    }
}
```

License
-------

[](#license)

Copyright © 2019 José Lorente Martín .

Licensed under the BSD 3-Clause License. See LICENSE.txt for details.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

Total

3

Last Release

2059d ago

### Community

Maintainers

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

---

Top Contributors

[![jlorente](https://avatars.githubusercontent.com/u/301741?v=4)](https://github.com/jlorente "jlorente (8 commits)")

---

Tags

auditablecreated-bydeleted-byidentitylaravelupdated-byuserstampuserstampsphplaravelidentitycreated\_byupdated\_bydeleted\_byjlorenteAuditableidentitystamp

### Embed Badge

![Health badge](/badges/jlorente-laravel-identitystamps/health.svg)

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

###  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)[josiasmontag/laravel-recaptchav3

Recaptcha V3 for Laravel package

2641.6M2](/packages/josiasmontag-laravel-recaptchav3)[shanmuga/laravel-entrust

This package provides a flexible solution to add ACL to Laravel

68312.9k2](/packages/shanmuga-laravel-entrust)

PHPackages © 2026

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