Skip to content

Commit 170d4f4

Browse files
committed
log creation in a single query
1 parent 3d92254 commit 170d4f4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Traits/BalanceOperation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected function createLog(string $logType, int|float $value, ?string $notes =
4949

5050
$newBalance = $logType === 'dec' ? $currentBalance - $value : $currentBalance + $value;
5151

52-
$this->createdLog = $this->logs()->create([
52+
$walletLog = (new WalletsLog())->fill([
5353
'wallet_name' => $this->type->value,
5454
'from' => $currentBalance,
5555
'to' => $newBalance,
@@ -60,7 +60,9 @@ protected function createLog(string $logType, int|float $value, ?string $notes =
6060
'reference' => $this->generateReference(),
6161
]);
6262

63-
$this->createdLog->changeStatus('Done');
63+
$walletLog->status = 'Done';
64+
65+
$this->createdLog = $this->logs()->save($walletLog);
6466
}
6567

6668
/**

0 commit comments

Comments
 (0)