API reference
Auditable: Record Changes of Eloquent Models
The Auditable trait listens to the created, updated, deleted and restored events of a model and writes an activity for each of them.
php
use Illuminate\Database\Eloquent\Model;
use Waypoint\Auditable;
class Invoice extends Model
{
use Auditable;
}
Properties
Property
Type
Description
$auditarrayAttributes to log, defaults to all fillable attributes
$auditExceptarrayAttributes never to log, e.g.
password$auditEventsarrayModel events to log, defaults to all four
$auditEmptyboolLog updates without changed attributes, defaults to
falseMethods
activities()
Returns a MorphMany relation with all activities of the model, newest first.
php
$invoice->activities()->with('causer')->limit(20)->get();
withoutAuditing(callable $callback)
Runs the callback without writing activities for this model class. Use it for imports and data migrations.
Caution
Changes made inside the callback can't be traced or restored from the audit log later.
php
Invoice::withoutAuditing(function () {
Invoice::query()->update(['currency' => 'EUR']);
});
auditDescription(string $event)
Override this method to store a readable description like "Invoice INV-1042 was paid". It is shown in the activity feed instead of the event name.
Last updated: