@@ -55,7 +55,7 @@ private function checkAmount(int $amount): void
5555 public function forceWithdraw (int $ amount , ?array $ meta = null , bool $ confirmed = true ): Transaction
5656 {
5757 $ this ->checkAmount ($ amount );
58- return $ this ->change (-$ amount , $ meta , $ confirmed );
58+ return $ this ->change (Transaction:: TYPE_WITHDRAW , -$ amount , $ meta , $ confirmed );
5959 }
6060
6161 /**
@@ -70,7 +70,7 @@ public function forceWithdraw(int $amount, ?array $meta = null, bool $confirmed
7070 public function deposit (int $ amount , ?array $ meta = null , bool $ confirmed = true ): Transaction
7171 {
7272 $ this ->checkAmount ($ amount );
73- return $ this ->change ($ amount , $ meta , $ confirmed );
73+ return $ this ->change (Transaction:: TYPE_DEPOSIT , $ amount , $ meta , $ confirmed );
7474 }
7575
7676 /**
@@ -190,15 +190,16 @@ protected function assemble(Wallet $wallet, Transaction $withdraw, Transaction $
190190 /**
191191 * this method adds a new transaction to the translation table
192192 *
193+ * @param string $type
193194 * @param int $amount
194195 * @param array|null $meta
195196 * @param bool $confirmed
196197 * @return Transaction
197198 * @throws
198199 */
199- protected function change (int $ amount , ?array $ meta , bool $ confirmed ): Transaction
200+ protected function change (string $ type , int $ amount , ?array $ meta , bool $ confirmed ): Transaction
200201 {
201- return DB ::transaction (function () use ($ amount , $ meta , $ confirmed ) {
202+ return DB ::transaction (function () use ($ type , $ amount , $ meta , $ confirmed ) {
202203
203204 $ wallet = $ this ;
204205 if (!($ this instanceof WalletModel)) {
@@ -210,7 +211,7 @@ protected function change(int $amount, ?array $meta, bool $confirmed): Transacti
210211 }
211212
212213 return $ this ->transactions ()->create ([
213- 'type ' => $ amount > 0 ? ' deposit ' : ' withdraw ' ,
214+ 'type ' => $ type ,
214215 'wallet_id ' => $ wallet ->getKey (),
215216 'uuid ' => Uuid::uuid4 ()->toString (),
216217 'confirmed ' => $ confirmed ,
0 commit comments