'integer', 'balance_after' => 'integer', ]; } public function amountFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->amount, 0, ',', '.'), ); } public function balanceAfterFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->balance_after, 0, ',', '.'), ); } public function referenceLabel(): Attribute { return Attribute::make( get: fn () => self::labelForReferenceType($this->reference_type), ); } public function isIncoming(): Attribute { return Attribute::make( get: fn () => self::isIncomingReference($this->reference_type), ); } public function createdAtFormatted(): Attribute { return Attribute::make( get: fn () => $this->created_at?->translatedFormat('l, d F Y H:i'), ); } public function createdByName(): Attribute { return Attribute::make( get: fn () => $this->createdBy?->profile?->full_name ?? $this->createdBy?->username, ); } public static function labelForReferenceType(?string $referenceType): string { if ($referenceType === null) { return 'Setor Kas'; } return match ($referenceType) { Expense::class => 'Pengeluaran', default => class_basename($referenceType), }; } public static function isIncomingReference(?string $referenceType): bool { if ($referenceType === null) { return true; } return match ($referenceType) { default => false, }; } public function cashAccount(): BelongsTo { return $this->belongsTo(CashAccount::class); } public function createdBy(): BelongsTo { return $this->belongsTo(User::class, 'created_by_id'); } public function reference(): MorphTo { return $this->morphTo(); } }