Guides
Log Custom Events with Waypoint
Not everything worth logging is a model change. Logins, downloads, approvals and exports belong in the audit trail as well.
Log an event
php
use Waypoint\Facades\Waypoint;
Waypoint::log('approved')
->on($expense)
->with(['amount' => $expense->amount])
->save();
Log authentication events
Listen to the auth events of Laravel to record logins:
php
use Illuminate\Auth\Events\Login;
use Waypoint\Facades\Waypoint;
class LogSuccessfulLogin
{
public function handle(Login $event): void
{
Waypoint::log('login')->on($event->user)->with(['ip' => request()->ip()])->save();
}
}
Note
Custom events show up in
activities()of the subject just like model changes, so one query returns the whole history.
Last updated: