Laravel Userstamps provides an Eloquent trait that automatically maintains created_by and updated_by columns on your model, populated by the currently authenticated user in your application. Your model must include a created_by and updated_by column, defaulting to null.

use Wildside\Userstamps\Userstamps; class Foo extends Model { use Userstamps; const CREATED_BY = 'alt_created_by'; const UPDATED_BY = 'alt_updated_by'; const DELETED_BY = 'alt_deleted_by'; }

$model->creator; // the user who created the model $model->editor; // the user who last updated the model $model->destroyer; // the user who deleted the model

In this example, model relations are updated via Eloquent and userstamps will be maintained: $model->foos->each(function ($item) { $item->bar = 'x'; $item->save(); }); However, in this example, model relations are bulk updated and bypass Eloquent.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners