We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3eb673a commit abb255eCopy full SHA for abb255e
src/Models/Wallet.php
@@ -71,15 +71,22 @@ public function setNameAttribute(string $name): void
71
}
72
73
/**
74
- * @return bool
+ * @return int
75
*/
76
- public function calculateBalance(): bool
+ public function getAvailableBalance(): int
77
{
78
- $balance = $this->transactions()
+ return $this->transactions()
79
->where('wallet_id', $this->getKey())
80
->where('confirmed', true)
81
->sum('amount');
82
+ }
83
84
+ /**
85
+ * @return bool
86
+ */
87
+ public function calculateBalance(): bool
88
+ {
89
+ $balance = $this->getBalanceAttribute();
90
WalletProxy::set($this->getKey(), $balance);
91
$this->attributes['balance'] = $balance;
92
0 commit comments