EmployeeAdvanceStatus::class, 'amount' => 'integer', 'paid_amount' => 'integer', 'due_date' => 'date:Y-m-d', 'verified_at' => 'datetime', 'paid_at' => 'datetime', ]; } protected function formattedAmount(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->amount, 0, ',', '.'), ); } protected function formattedCreatedAt(): Attribute { return Attribute::make( get: fn () => $this->created_at?->translatedFormat('l, d F Y'), ); } protected function formattedDueDate(): Attribute { return Attribute::make( get: fn () => $this->due_date?->translatedFormat('l, d F Y'), ); } protected function formattedPaidAmount(): Attribute { return Attribute::make( get: fn () => 'Rp '.number_format($this->paid_amount, 0, ',', '.'), ); } protected function statusLabel(): Attribute { return Attribute::make( get: fn () => $this->status->label(), ); } #[Scope] protected function approved(Builder $query): void { $query->where('status', EmployeeAdvanceStatus::APPROVED); } #[Scope] protected function cancelled(Builder $query): void { $query->where('status', EmployeeAdvanceStatus::CANCELLED); } #[Scope] protected function paid(Builder $query): void { $query->where('status', EmployeeAdvanceStatus::PAID); } #[Scope] protected function pending(Builder $query): void { $query->where('status', EmployeeAdvanceStatus::PENDING); } #[Scope] protected function rejected(Builder $query): void { $query->where('status', EmployeeAdvanceStatus::REJECTED); } public function cashTransaction(): BelongsTo { return $this->belongsTo(CashTransaction::class); } public function employee(): BelongsTo { return $this->belongsTo(Employee::class); } public function paidBy(): BelongsTo { return $this->belongsTo(User::class, 'paid_by_id'); } 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'); } }