PHPackages                             phpfour/laravel-userstamps-for-backpack - 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. phpfour/laravel-userstamps-for-backpack

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

phpfour/laravel-userstamps-for-backpack
=======================================

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. This forks make that work for Backpack for Laravel.

1.0.1(2y ago)11191MITPHPPHP &gt;=5.5.9

Since Sep 30Pushed 2y agoCompare

[ Source](https://github.com/phpfour/Laravel-Userstamps-for-Backpack)[ Packagist](https://packagist.org/packages/phpfour/laravel-userstamps-for-backpack)[ RSS](/packages/phpfour-laravel-userstamps-for-backpack/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

 [![](https://camo.githubusercontent.com/64a781e698b8668d7c5b477e6ddb775a4e35bad3c63100c54f83abf827f43aa0/68747470733a2f2f73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f77732e686f737465642f757365727374616d70732d6c6f676f2e737667)](https://camo.githubusercontent.com/64a781e698b8668d7c5b477e6ddb775a4e35bad3c63100c54f83abf827f43aa0/68747470733a2f2f73332d65752d776573742d312e616d617a6f6e6177732e636f6d2f77732e686f737465642f757365727374616d70732d6c6f676f2e737667)

 [ ![Build Status](https://camo.githubusercontent.com/e8fce1662734f835375541e937b618e9350aa85c67148acc089cae08f35a708d/68747470733a2f2f7472617669732d63692e636f6d2f57696c6453696465554b2f4c61726176656c2d557365727374616d70732e737667) ](https://travis-ci.com/WildSideUK/Laravel-Userstamps) [ ![Total Downloads](https://camo.githubusercontent.com/270ea331c0dfebd4f08e94909adee16d6a4c0eb06758c0df85a83062a4924bd8/68747470733a2f2f706f7365722e707567782e6f72672f77696c64736964652f757365727374616d70732f642f746f74616c2e737667) ](https://packagist.org/packages/wildside/userstamps) [ ![Latest Stable Version](https://camo.githubusercontent.com/2d631933eae2e2c51eefb61e605109ca2e33f68f03b4f914488a07753e92f27a/68747470733a2f2f706f7365722e707567782e6f72672f77696c64736964652f757365727374616d70732f762f737461626c652e737667) ](https://packagist.org/packages/wildside/userstamps) [ ![License](https://camo.githubusercontent.com/8c581440aa3c79610a436a19f5bc46b44106bdd697ccb2a09027d61a248002be/68747470733a2f2f706f7365722e707567782e6f72672f77696c64736964652f757365727374616d70732f6c6963656e73652e737667) ](https://packagist.org/packages/wildside/userstamps)

About Laravel Userstamps
------------------------

[](#about-laravel-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.

When using the Laravel `SoftDeletes` trait, a `deleted_by` column is also handled by this package.

Installing
----------

[](#installing)

This package requires Laravel 5.2 or later running on PHP 5.6 or higher.

This package can be installed using composer:

```
composer require wildside/userstamps

```

Usage
-----

[](#usage)

Your model will need to include a `created_by` and `updated_by` column, defaulting to `null`.

If using the Laravel `SoftDeletes` trait, it will also need a `deleted_by` column.

The column type should match the type of the ID column in your user's table. In Laravel &lt;= 5.7 this defaults to `unsignedInteger`. For Laravel &gt;= 5.8 this defaults to `unsignedBigInteger`.

An example migration:

```
$table->unsignedBigInteger('created_by')->nullable();
$table->unsignedBigInteger('updated_by')->nullable();
```

You can now load the trait within your model, and userstamps will automatically be maintained:

```
use Wildside\Userstamps\Userstamps;

class Foo extends Model {

    use Userstamps;
}
```

Optionally, should you wish to override the names of the `created_by`, `updated_by` or `deleted_by` columns, you can do so by setting the appropriate class constants on your model. Ensure you match these column names in your migration.

```
use Wildside\Userstamps\Userstamps;

class Foo extends Model {

    use Userstamps;

    const CREATED_BY = 'alt_created_by';
    const UPDATED_BY = 'alt_updated_by';
    const DELETED_BY = 'alt_deleted_by';
}
```

When using this trait, helper relationships are available to let you retrieve the user who created, updated and deleted (when using the Laravel `SoftDeletes` trait) your model.

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

Methods are also available to temporarily stop the automatic maintaining of userstamps on your models:

```
$model->stopUserstamping(); // stops userstamps being maintained on the model
$model->startUserstamping(); // resumes userstamps being maintained on the model
```

Workarounds
-----------

[](#workarounds)

This package works by hooking into Eloquent's model event listeners, and is subject to the same limitations of all such listeners.

When you make changes to models that bypass Eloquent, the event listeners won't be fired and userstamps will not be updated.

Commonly this will happen if bulk updating or deleting models, or their relations.

In this example, model relations are updated via Eloquent and userstamps **will** be maintained:

```
$model->foos->each(function ($item) {
    $item->bar = 'x';
    $item->save();
});
```

However in this example, model relations are bulk updated and bypass Eloquent. Userstamps **will not** be maintained:

```
$model->foos()->update([
    'bar' => 'x',
]);
```

As a workaroud to this issue two helper methods are available - `updateWithUserstamps` and `deleteWithUserstamps`. Their behaviour is identical to `update` and `delete`, but they ensure the `updated_by` and `deleted_by` properties are maintained on the model.

You generally won't have to use these methods, unless making bulk updates that bypass Eloquent events.

In this example, models are bulk updated and userstamps **will not** be maintained:

```
$model->where('name', 'foo')->update([
    'name' => 'bar',
]);
```

However in this example, models are bulk updated using the helper method and userstamps **will** be maintained:

```
$model->where('name', 'foo')->updateWithUserstamps([
    'name' => 'bar',
]);
```

Sponsors
--------

[](#sponsors)

[ ![](https://camo.githubusercontent.com/2075cef2039dc595f7ff089b1fca4e8fc40679796a94b3ca2f3cef9dcbe6e0ca/68747470733a2f2f77696c64736964652e756b2f696d616765732f77696c64736964652d6c6f676f2e737667)](https://wildside.uk)This open-source software is developed and maintained by [WILDSIDE](https://wildside.uk).

License
-------

[](#license)

This open-source software is licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor4

4 contributors hold 50%+ of commits

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

Total

2

Last Release

915d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cc69da0be0755785328ca1f241df07ab758522efa22efee8f39dbc78eaaa276?d=identicon)[phpfour](/maintainers/phpfour)

---

Top Contributors

[![tkayfun](https://avatars.githubusercontent.com/u/10990971?v=4)](https://github.com/tkayfun "tkayfun (2 commits)")[![phpfour](https://avatars.githubusercontent.com/u/171715?v=4)](https://github.com/phpfour "phpfour (2 commits)")[![mahmoudmohamedramadan](https://avatars.githubusercontent.com/u/48416569?v=4)](https://github.com/mahmoudmohamedramadan "mahmoudmohamedramadan (1 commits)")[![mazyvan](https://avatars.githubusercontent.com/u/10915753?v=4)](https://github.com/mazyvan "mazyvan (1 commits)")[![geisi](https://avatars.githubusercontent.com/u/10728579?v=4)](https://github.com/geisi "geisi (1 commits)")[![RomeroMsk](https://avatars.githubusercontent.com/u/4639951?v=4)](https://github.com/RomeroMsk "RomeroMsk (1 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (1 commits)")[![tacone](https://avatars.githubusercontent.com/u/659801?v=4)](https://github.com/tacone "tacone (1 commits)")[![JustinByrne](https://avatars.githubusercontent.com/u/14056930?v=4)](https://github.com/JustinByrne "JustinByrne (1 commits)")

---

Tags

laraveleloquentaddonuserstampscreated\_byupdated\_bydeleted\_bybackpackBackpack for Laravel

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpfour-laravel-userstamps-for-backpack/health.svg)

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

###  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)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)

PHPackages © 2026

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