File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed
Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -12,13 +12,9 @@ public function deposit(int|float $amount): float|int
1212 {
1313 $ this ->throwExceptionIfAmountIsInvalid ($ amount );
1414
15- $ balance = $ this ->wallet_balance ?? 0 ;
16-
17- $ balance += $ amount ;
15+ $ this ->increment ('wallet_balance ' , $ amount );
1816
19- $ this ->forceFill (['wallet_balance ' => $ balance ])->save ();
20-
21- return $ balance ;
17+ return $ this ->wallet_balance ;
2218 }
2319
2420 public function withdraw (int |float $ amount ): float |int
@@ -27,11 +23,9 @@ public function withdraw(int|float $amount): float|int
2723
2824 $ this ->throwExceptionIfFundIsInsufficient ($ amount );
2925
30- $ balance = $ this ->wallet_balance - $ amount ;
31-
32- $ this ->forceFill (['wallet_balance ' => $ balance ])->save ();
26+ $ this ->decrement ('wallet_balance ' , $ amount );
3327
34- return $ balance ;
28+ return $ this -> wallet_balance ;
3529 }
3630
3731 public function canWithdraw (int |float $ amount ): bool
You can’t perform that action at this time.
0 commit comments