Description
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.
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.
Userstamp columns can be created using:
$table->userstamps();$table->userstampSoftDeletes();
Equivalent methods are also available when working with UUIDs.
$table->userstampsUuid();$table->userstampsUuidSoftDeletes();
You can now load the trait within your model, and userstamps will automatically be maintained:
use Mattiverse\Userstamps\Traits\Userstamps; class Foo extends Model { use Userstamps;}
Recent Courses on Laravel Daily
[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Queues in Laravel 13
18 lessons
1 h 12 min read
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read