Skip to content

Commit c954623

Browse files
committed
update method "add balance"
1 parent d71841d commit c954623

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Traits/HasWallet.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,12 @@ protected function addBalance(WalletModel $wallet, int $amount): bool
358358
$newBalance = $this->getBalanceAttribute() + $amount;
359359
$wallet->balance = $newBalance;
360360

361-
if ($wallet->save()) {
362-
WalletProxy::set($wallet->getKey(), $newBalance);
363-
return true;
364-
}
361+
return
362+
// update database wallet
363+
$wallet->save() &&
365364

366-
return false;
365+
// update static wallet
366+
WalletProxy::set($wallet->getKey(), $newBalance);
367367
}
368368

369369
}

src/WalletProxy.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ public static function get(int $key): int
3131
/**
3232
* @param int $key
3333
* @param int $value
34+
* @return bool
3435
*/
35-
public static function set(int $key, int $value): void
36+
public static function set(int $key, int $value): bool
3637
{
3738
static::$rows[$key] = $value;
39+
return true;
3840
}
3941

4042
/**

0 commit comments

Comments
 (0)