Skip to main content
Back to packages
753 GitHub stars

WildsideUK/Laravel-Userstamps

View on GitHub

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