我正在学习使用spatie/laravel-activitylog
包在 Laravel(7.1) 中记录活动。但是当我更新用户时,它不会更新表properties
中的列activity_log
,我在模型( )上设置$logAttributes
了属性protected static $logAttributes = ['name', 'email'];
当我更新用户时
>>> $user = User::find(1);
=> App\User {#3104
id: 1,
name: "John",
email: "prath@example.com",
email_verified_at: "2020-03-12 13:35:19",
created_at: "2020-03-12 13:35:19",
updated_at: "2020-03-12 13:41:34",
}
>>> $user->update(['name' => 'James']);
=> true
它记录该活动,但返回一个空的属性列。
{
id: 8,
log_name: "default",
description: "updated",
subject_id: 1,
subject_type: "App\User",
causer_id: null,
causer_type: null,
properties: [ ],
created_at: "2020-03-12T14:58:10.000000Z",
updated_at: "2020-03-12T14:58:10.000000Z"
}