'hashed', ]; } protected function name(): Attribute { return Attribute::make( get: fn () => $this->profile?->full_name ?? $this->username ); } public function expenses(): HasMany { return $this->hasMany(Expense::class); } public function payrolls(): HasMany { return $this->hasMany(Payroll::class); } public function profile(): HasOne { return $this->hasOne(UserProfile::class); } public function salaryHistories(): HasMany { return $this->hasMany(SalaryHistory::class); } public function getActivitylogOptions(): LogOptions { return LogOptions::defaults() ->logOnly(['username']) ->logOnlyDirty() ->useLogName('Pegawai'); } 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 = [ 'username' => 'Username', ]; $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); } } }