Video
Premium
Description
Provides easy to use functions to log the activities of the users of your app.
Here's a demo of how you can use it:
activity()->log('Look, I logged something');
You can retrieve all activity using the Spatie\Activitylog\Models\Activity model.
Activity::all();
Here's a more advanced example:
activity()
->performedOn($anEloquentModel)
->causedBy($user)
->withProperties(['customProperty' => 'customValue'])
->log('Look, I logged something');
$lastLoggedActivity = Activity::all()->last();
$lastLoggedActivity->subject; //returns an instance of an eloquent model
$lastLoggedActivity->causer; //returns an instance of your user model
$lastLoggedActivity->getProperty('customProperty'); //returns 'customValue'
$lastLoggedActivity->description; //returns 'Look, I logged something'
Related Content on Laravel Daily
Video
Video
Premium
Spatie Activity Log Package: Deeper Dive
Video
Recent Courses on Laravel Daily
[NEW] Next.js Basics for Laravel Developers
11 lessons
58 min
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read
[FREE] Laravel 13 for Beginners: 3 Demo Projects
5 lessons
29 min