'date', 'amount' => 'decimal:2', ]; // Relationships public function budgetItem(): BelongsTo { return $this->belongsTo(BudgetItem::class); } public function chartOfAccount(): BelongsTo { return $this->belongsTo(ChartOfAccount::class); } public function financeDocument(): BelongsTo { return $this->belongsTo(FinanceDocument::class); } public function membershipPayment(): BelongsTo { return $this->belongsTo(MembershipPayment::class); } public function createdBy(): BelongsTo { return $this->belongsTo(User::class, 'created_by_user_id'); } // Helper methods public function isIncome(): bool { return $this->transaction_type === 'income'; } public function isExpense(): bool { return $this->transaction_type === 'expense'; } // Scopes public function scopeIncome($query) { return $query->where('transaction_type', 'income'); } public function scopeExpense($query) { return $query->where('transaction_type', 'expense'); } public function scopeForPeriod($query, $startDate, $endDate) { return $query->whereBetween('transaction_date', [$startDate, $endDate]); } }