'integer', 'new_salary' => 'integer', ]; } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logOnly(['old_salary', 'new_salary']) ->logOnlyDirty() ->useLogName('Riwayat Gaji'); } public function tapActivity(Activity $activity, string $eventName) { $activity->description = match ($eventName) { 'created' => 'TAMBAH', 'updated' => 'UBAH', 'deleted' => 'HAPUS', default => $activity->description, }; if (isset($activity->properties['attributes'])) { $attributeMap = [ 'old_salary' => 'Gaji Lama', 'new_salary' => 'Gaji Baru', ]; $properties = $activity->properties->toArray(); $localizeValues = function ($attrs) use ($attributeMap) { $newAttrs = []; foreach ($attrs as $key => $value) { $label = $attributeMap[$key] ?? $key; $newAttrs[$label] = $value; } return $newAttrs; }; $properties['attributes'] = $localizeValues($properties['attributes']); if (isset($properties['old'])) { $properties['old'] = $localizeValues($properties['old']); } $activity->properties = collect($properties); } } }