-
I want to change the value of log_name 'default' to the user that has made the changes. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey, if you have an instance of the laravel-activitylog/src/ActivityLogger.php Lines 115 to 125 in 469e78d If you want to set the log name on model event logs you can use the tapActivity() method on each model to set the log_name attribute of the Activity model instance passed in.The third option would be to use the Macroable trait of ActivityLogger class and add a method that can override the defaultLogName property on runtime. This will change the log name for every activity without a defined one after the method is called.
At all I don't recommend to do this. Because the causing user is already saved as a relationship on the model and the log name/channel is more for different areas of your app for example. So like admin and user logs. |
Beta Was this translation helpful? Give feedback.
Hey,
if you have an instance of the
ActivityLogger
you can use one of these two methods to define it on runtime.laravel-activitylog/src/ActivityLogger.php
Lines 115 to 125 in 469e78d
If you want to set the log name on model event logs you can use the
tapActivity()
method on each model to set thelog_name
attribute of theActivity
model instance passed in.The third option would be to use the
Macroable
trait ofActivityLogger
class and add a method …