2

I am using Laravel Spatie Activity Log package in my laravel application. I could customize in each module.

 public function tapActivity(Activity $activity, string $eventName)
 {
    $activity->description = "Category is {$eventName}. ";
    $activity->os = getOS();// custom hlper
 }

This problem was when I was going to save ip.

$activity->ip = $request->ip();

I think above field should be added. But where can we get $request ?

apokryfos
  • 38,771
  • 9
  • 70
  • 114
LoveCoding
  • 1,121
  • 2
  • 12
  • 33

1 Answers1

2

I solved this myself.

$activity->ip = request()->ip();

This just worked. :)

LoveCoding
  • 1,121
  • 2
  • 12
  • 33