fix(activity): 修正操作紀錄列表描述中未顯示使用者名稱的問題
- 在 User 模型中加入 tapActivity 自動記錄 snapshot (name, username) - 在 UserController 手動紀錄的邏輯中補上 snapshot
This commit is contained in:
@@ -57,4 +57,14 @@ class User extends Authenticatable
|
||||
->logOnlyDirty()
|
||||
->dontSubmitEmptyLogs();
|
||||
}
|
||||
|
||||
public function tapActivity(\Spatie\Activitylog\Contracts\Activity $activity, string $eventName)
|
||||
{
|
||||
$activity->properties = $activity->properties->merge([
|
||||
'snapshot' => [
|
||||
'name' => $this->name,
|
||||
'username' => $this->username,
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user