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
Laravel 13 Starter Kit Teams and Customizations
10 lessons
33 min
How to Build Laravel 13 API From Scratch
30 lessons
1 h 23 min