88use Bavix \Wallet \Models \Transfer ;
99use Bavix \Wallet \Models \Wallet as WalletModel ;
1010use Bavix \Wallet \Services \CommonService ;
11+ use Bavix \Wallet \Services \DbService ;
1112use Bavix \Wallet \Services \WalletService ;
1213use Illuminate \Database \Eloquent \Relations \MorphMany ;
1314use Illuminate \Support \Collection ;
14- use Illuminate \Support \Facades \DB ;
1515use Throwable ;
1616use function app ;
1717use function config ;
@@ -37,11 +37,12 @@ trait HasWallet
3737 * @param bool $confirmed
3838 *
3939 * @return Transaction
40+ * @throws
4041 */
4142 public function deposit (int $ amount , ?array $ meta = null , bool $ confirmed = true ): Transaction
4243 {
4344 $ self = $ this ;
44- return DB :: transaction (static function () use ($ self , $ amount , $ meta , $ confirmed ) {
45+ return app (DbService::class)-> transaction (static function () use ($ self , $ amount , $ meta , $ confirmed ) {
4546 return app (CommonService::class)
4647 ->deposit ($ self , $ amount , $ meta , $ confirmed );
4748 });
@@ -161,11 +162,12 @@ public function canWithdraw(int $amount, bool $allowZero = null): bool
161162 * @param bool $confirmed
162163 *
163164 * @return Transaction
165+ * @throws
164166 */
165167 public function forceWithdraw (int $ amount , ?array $ meta = null , bool $ confirmed = true ): Transaction
166168 {
167169 $ self = $ this ;
168- return DB :: transaction (static function () use ($ self , $ amount , $ meta , $ confirmed ) {
170+ return app (DbService::class)-> transaction (static function () use ($ self , $ amount , $ meta , $ confirmed ) {
169171 return app (CommonService::class)
170172 ->forceWithdraw ($ self , $ amount , $ meta , $ confirmed );
171173 });
@@ -179,11 +181,12 @@ public function forceWithdraw(int $amount, ?array $meta = null, bool $confirmed
179181 * @param int $amount
180182 * @param array|null $meta
181183 * @return Transfer
184+ * @throws
182185 */
183186 public function forceTransfer (Wallet $ wallet , int $ amount , ?array $ meta = null ): Transfer
184187 {
185188 $ self = $ this ;
186- return DB :: transaction (static function () use ($ self , $ amount , $ wallet , $ meta ) {
189+ return app (DbService::class)-> transaction (static function () use ($ self , $ amount , $ wallet , $ meta ) {
187190 return app (CommonService::class)
188191 ->forceTransfer ($ self , $ wallet , $ amount , $ meta );
189192 });
0 commit comments