SalaryAdjustmentType::class, 'amount' => 'integer', ]; } protected function amountFormatted(): Attribute { return Attribute::make( get: fn () => $this->amount ? 'Rp '.number_format($this->amount, 0, ',', '.') : null, ); } public function payroll(): BelongsTo { return $this->belongsTo(Payroll::class); } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logOnly(['type', 'description', 'amount']) ->logOnlyDirty() ->useLogName('Penyesuaian 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 = [ 'type' => 'Jenis', 'description' => 'Keterangan', 'amount' => 'Nominal', ]; $properties = $activity->properties->toArray(); $localizeValues = function ($attrs) use ($attributeMap) { $newAttrs = []; foreach ($attrs as $key => $value) { $label = $attributeMap[$key] ?? $key; $displayValue = $value; if ($key === 'type' && $value instanceof \BackedEnum) { $displayValue = $value->value; } $newAttrs[$label] = $displayValue; } return $newAttrs; }; $properties['attributes'] = $localizeValues($properties['attributes']); if (isset($properties['old'])) { $properties['old'] = $localizeValues($properties['old']); } $activity->properties = collect($properties); } } }