Laravel-Backpack / activity-log

MIT License
23 stars 6 forks source link

[Feature Request] can you save address ip of user or admin #35

Closed haythembekir20 closed 7 months ago

haythembekir20 commented 8 months ago

can you add feature to save address ip of user or admin

karandatwani92 commented 8 months ago

Relates to:

promatik commented 7 months ago

Hi @haythembekir20!

This package is just a "frontend" for the spatie/laravel-activitylog. So this request should be handled in the main package way. I'll just copy here the answer given at https://github.com/spatie/laravel-activitylog/issues/39, it will be enough to save the IP address.

AppServiceProvider.php

Activity::saving(function (Activity $activity) {
    $activity->properties = $activity->properties->put('ip', request()->ip());
});

Let us know if it works for you 🙌