'integer', 'bonus' => 'integer', 'deduction' => 'integer', 'total_salary' => 'integer', 'is_paid' => 'boolean', ]; } protected function baseSalaryFormatted(): Attribute { return Attribute::make( get: fn () => $this->base_salary ? 'Rp '.number_format($this->base_salary, 0, ',', '.') : null, ); } protected function bonusFormatted(): Attribute { return Attribute::make( get: fn () => $this->bonus ? 'Rp '.number_format($this->bonus, 0, ',', '.') : null, ); } protected function deductionFormatted(): Attribute { return Attribute::make( get: fn () => $this->deduction ? 'Rp '.number_format($this->deduction, 0, ',', '.') : null, ); } protected function totalSalaryFormatted(): Attribute { return Attribute::make( get: fn () => $this->total_salary ? 'Rp '.number_format($this->total_salary, 0, ',', '.') : null, ); } protected function periodMonthFormatted(): Attribute { return Attribute::make( get: fn () => $this->period_month ? Carbon::parse($this->period_month)->translatedFormat('F Y') : null, ); } public function adjustments(): HasMany { return $this->hasMany(PayrollAdjustment::class); } public function user(): BelongsTo { return $this->belongsTo(User::class); } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logOnly(['base_salary', 'bonus', 'deduction', 'total_salary', 'is_paid', 'period_month']) ->logOnlyDirty() ->useLogName('Penggajian'); } 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 = [ 'base_salary' => 'Gaji Pokok', 'bonus' => 'Bonus', 'deduction' => 'Potongan', 'total_salary' => 'Total Gaji', 'is_paid' => 'Status Pembayaran', 'period_month' => 'Periode', ]; $properties = $activity->properties->toArray(); $localizeValues = function ($attrs) use ($attributeMap) { $newAttrs = []; foreach ($attrs as $key => $value) { $label = $attributeMap[$key] ?? $key; $displayValue = $value; if ($key === 'is_paid') { $displayValue = $value ? 'Dibayar' : 'Belum Dibayar'; } $newAttrs[$label] = $displayValue; } return $newAttrs; }; $properties['attributes'] = $localizeValues($properties['attributes']); if (isset($properties['old'])) { $properties['old'] = $localizeValues($properties['old']); } $activity->properties = collect($properties); } } }