kayiwarahim / laravel-userstamps
A simple Laravel package for Eloquent Model user specific fields by Rahim.
v6.0.0
2025-03-01 00:00 UTC
Requires
- php: ^7.2 || ^8.0 || ^8.1 || ^8.2
- illuminate/database: ^6.0 || ^9.0 || ^10.0
- illuminate/support: ^6.0 || ^9.0 || ^10.0
This package is auto-updated.
Last update: 2025-06-29 12:45:12 UTC
README
Laravel Userstamps is a simple Laravel package for your Eloquent Model user specific fields. This package automatically inserts/updates an user id on your table on who created, last updated and deleted the record.
Install
- Add repositories in composer.json
"repositories": [
{
"url": "https://github.com/kayiwarahim/laravel-userstamps.git",
"type": "git"
}
],
- Add the package name in
composer.json
require section:- For Laravel 5.x use v1.0.1
"hrshadhin/laravel-userstamps": "^1.0.0"
- For Laravel 6.x use v2.0.1
"hrshadhin/laravel-userstamps": "^2.0.0"
- For Laravel 7.x use v3.0.0
"hrshadhin/laravel-userstamps": "^3.0.0"
- For Laravel 8.x use v4.0.0
"hrshadhin/laravel-userstamps": "^4.0.0"
- For Laravel 9.x use v5.0.0
"hrshadhin/laravel-userstamps": "^5.0.0"
- For Laravel 10.x use v6.0.0
"kayiwarahim/laravel-userstamps": "^6.0.0"
Usage
Update your model's migration and add created_by
, updated_by
and deleted_by
field using the userstamps()
blueprint macro.
Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name', 100); $table->userstamps(); $table->timestamps(); });
Then use UserstampsTrait
on your model.
namespace App; use Hrshadhin\Userstamps\UserstampsTrait; class User extends Model { use UserstampsTrait; }
Dropping columns
You can drop auditable columns using dropUserstamps()
method.
Schema::create('users', function (Blueprint $table) { $table->dropUserstamps(); });
And your done!
License
The MIT License (MIT). Please see License File for more information.