addMediaCollection('photos'); } protected function casts(): array { return [ 'amount' => 'integer', 'due_date' => 'date', 'status' => EmployeeAdvanceStatus::class, 'verified_at' => 'datetime', 'paid_at' => 'datetime', ]; } public function amountFormatted(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->amount, 0, ',', '.'), ); } public function dueDateFormatted(): Attribute { return Attribute::make( get: fn () => $this->due_date?->translatedFormat('l, d F Y'), ); } public function dueDateInput(): Attribute { return Attribute::make( get: fn () => $this->due_date?->format('Y-m-d'), ); } public function statusLabel(): Attribute { return Attribute::make( get: fn () => $this->status?->label(), ); } public function employeeName(): Attribute { return Attribute::make( get: fn () => $this->employee?->user?->profile?->full_name ?? $this->employee?->user?->username, ); } public function rejectionReason(): Attribute { return Attribute::make( get: fn () => $this->rejection?->reason, ); } public function createdAtFormatted(): Attribute { return Attribute::make( get: fn () => $this->created_at?->translatedFormat('l, d F Y H:i'), ); } public function isEditable(): Attribute { return Attribute::make( get: fn () => $this->status === EmployeeAdvanceStatus::PENDING, ); } public function canVerify(): Attribute { return Attribute::make( get: fn () => $this->status === EmployeeAdvanceStatus::PENDING, ); } public function canPay(): Attribute { return Attribute::make( get: fn () => $this->status === EmployeeAdvanceStatus::APPROVED, ); } public function employee(): BelongsTo { return $this->belongsTo(Employee::class); } public function cashTransaction(): BelongsTo { return $this->belongsTo(CashTransaction::class); } public function repaymentCashTransaction(): BelongsTo { return $this->belongsTo(CashTransaction::class, 'repayment_cash_transaction_id'); } public function verifiedBy(): BelongsTo { return $this->belongsTo(User::class, 'verified_by_id'); } public function paidBy(): BelongsTo { return $this->belongsTo(User::class, 'paid_by_id'); } }