berthott / laravel-userstamps
Laravel Helper for Userstamps in Laravel
3.0.0
2023-02-16 10:03 UTC
Requires (Dev)
- orchestra/testbench: ^8.0
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-03-11 15:30:40 UTC
README
Laravel-Userstamps
A helper to maintain Userstamps in Laravel. Easily add and maintain userstamps by adding a trait to your model.
Installation
$ composer require berthott/laravel-userstamps
Usage
- Create your table and corresponding model, eg. with
php artisan make:model YourModel -m
- Add
$table->userstamps()
to your migration- If you use the
SoftDeletes
trait on your model additionally add$table->softDeletesUserstamp()
- If you use the
- Add the
HasUserstamps
trait to your newly generated model. - For some more macros see
\berthott\Userstamps\UserstampsServiceProvider::register()
creator()
,editor()
, anddestroyer()
will be available for your convenience.
Options
You may change the column names by adding these constants to your model.
const CREATED_BY = 'alt_created_by'; const UPDATED_BY = 'alt_updated_by'; const DELETED_BY = 'alt_deleted_by';
Note that in this case you cannot use $table->userstamps()
but need to define the columns separately with
$table->unsignedBigInteger('alt_created_by')->nullable(); $table->unsignedBigInteger('alt_updated_by')->nullable(); $table->unsignedBigInteger('alt_deleted_by')->nullable();
Compatibility
Tested with Laravel 10.x.
Credits
Inspired by https://github.com/WildsideUK/Laravel-Userstamps and https://github.com/hrshadhin/laravel-userstamps.
License
See License File. Copyright © 2023 Jan Bladt.