我正在使用 spatie / laravel activityLog包。
活动日志插入代码
$user = Auth::user();
$inventory = Inventory::where('id','=','1')->first();
$properties = ['action' => 'view'];
activity()
->performedOn($inventory)
->causedBy($user)
->withProperties($properties)
->log('add inventory')
->subject('test subject');
如何为特定模型实例填充活动日志?
下面是我的表
答案 0 :(得分:1)
这样可以正常使用
1)回答
LastName
2)回答
$inventory = new Inventory();
Activity::where('subject_type',get_class($inventory))->get();
如果您尝试第二个答案,那么
您只需在此路径中编辑以下功能 vendor / spatie / laravel-activitylog / src / models / Activity.php
$inventory = new Inventory();
Activity::forSubject($inventory)->get();