Skip to content

Commit abb255e

Browse files
committed
add getAvailableBalance
1 parent 3eb673a commit abb255e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Models/Wallet.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,22 @@ public function setNameAttribute(string $name): void
7171
}
7272

7373
/**
74-
* @return bool
74+
* @return int
7575
*/
76-
public function calculateBalance(): bool
76+
public function getAvailableBalance(): int
7777
{
78-
$balance = $this->transactions()
78+
return $this->transactions()
7979
->where('wallet_id', $this->getKey())
8080
->where('confirmed', true)
8181
->sum('amount');
82+
}
8283

84+
/**
85+
* @return bool
86+
*/
87+
public function calculateBalance(): bool
88+
{
89+
$balance = $this->getBalanceAttribute();
8390
WalletProxy::set($this->getKey(), $balance);
8491
$this->attributes['balance'] = $balance;
8592

0 commit comments

Comments
 (0)