diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 7f55913..be159cd 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -187,6 +187,15 @@ class UserController extends Controller ->causedBy(auth()->user()) ->event('updated') ->withProperties($properties) + ->tap(function (\Spatie\Activitylog\Contracts\Activity $activity) use ($user) { + // Manually add snapshot since we aren't using the model's LogOptions due to saveQuietly + $activity->properties = $activity->properties->merge([ + 'snapshot' => [ + 'name' => $user->name, + 'username' => $user->username, + ] + ]); + }) ->log('updated'); } diff --git a/app/Models/User.php b/app/Models/User.php index 6b85850..61092bc 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -57,4 +57,14 @@ class User extends Authenticatable ->logOnlyDirty() ->dontSubmitEmptyLogs(); } + + public function tapActivity(\Spatie\Activitylog\Contracts\Activity $activity, string $eventName) + { + $activity->properties = $activity->properties->merge([ + 'snapshot' => [ + 'name' => $this->name, + 'username' => $this->username, + ] + ]); + } }