API reference

Activity: Query and Display the Audit Log

Every logged change is stored as a Waypoint\Models\Activity. It is a normal Eloquent model, so you can query it like any other.

Attribute
Type
Description
event
string
Name of the event, e.g. updated
subject
Model
Model the activity belongs to
causer
?Model
User who made the change
changes
Collection
Old and new values of the changed attributes
batch_id
?string
Groups activities written by Waypoint::batch()
created_at
Carbon
Time of the change

Query scopes

php
use Waypoint\Models\Activity;

Activity::forSubject($invoice)
    ->causedBy($user)
    ->event('updated')
    ->between(now()->subWeek(), now())
    ->get();

Show the changes

changes contains the old and new value of every changed attribute. Loop over it to render a diff in Blade:

html
@foreach ($activity->changes as $attribute => $change)
    <dt>{{ $attribute }}</dt>
    <dd><del>{{ $change['old'] }}</del> <ins>{{ $change['new'] }}</ins></dd>
@endforeach

Last updated: