From c8adb19add1a12e4c183fb41e2a3b549e086eebd Mon Sep 17 00:00:00 2001 From: mac Date: Fri, 11 Dec 2020 23:07:27 +0300 Subject: [PATCH] bonus added --- src/Services/WalletService.php | 5 +++-- src/Traits/WalletTrait.php | 2 +- .../2020_11_16_202911_create_wallet_transactions_table.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Services/WalletService.php b/src/Services/WalletService.php index 5f8014a..add520d 100644 --- a/src/Services/WalletService.php +++ b/src/Services/WalletService.php @@ -12,7 +12,8 @@ class WalletService const TYPE_WITHDRAW = 'withdraw'; const TYPE_BET = 'bet'; const TYPE_WIN = 'win'; - const CYCLE_TYPES = ['deposit', 'bet']; + const TYPE_BONUS = 'bonus'; + const CYCLE_TYPES = ['deposit', 'bet', 'bonus']; public function create(WalletTransactionType $types) { $wallet = $types->getWallet(); @@ -24,7 +25,7 @@ public function create(WalletTransactionType $types) $wallet->balance = $wallet->balance + $types->getAmount(); $wallet->save(); } - if (($types->getType() == self::TYPE_DEPOSIT OR $types->getType() == self::TYPE_WIN) && $types->getConfirmed()) { + if (($types->getType() == self::TYPE_DEPOSIT OR $types->getType() == self::TYPE_WIN OR self::TYPE_BONUS) && $types->getConfirmed()) { $wallet->balance = $wallet->balance + $types->getAmount(); $wallet->save(); } diff --git a/src/Traits/WalletTrait.php b/src/Traits/WalletTrait.php index 863c626..81a54b7 100644 --- a/src/Traits/WalletTrait.php +++ b/src/Traits/WalletTrait.php @@ -34,7 +34,7 @@ public function withdraw($intermediary, $amount, $meta = [], $confirmed = 1) public function transaction($type, $intermediary, $amount, $meta = []) { - if(!in_array($type, [WalletService::TYPE_BET, WalletService::TYPE_WIN])) { + if(!in_array($type, [WalletService::TYPE_BET, WalletService::TYPE_WIN, WalletService::TYPE_BONUS])) { return false; } $types = new WalletTransactionType(); diff --git a/src/database/migrations/2020_11_16_202911_create_wallet_transactions_table.php b/src/database/migrations/2020_11_16_202911_create_wallet_transactions_table.php index b9406f1..6fff4ae 100644 --- a/src/database/migrations/2020_11_16_202911_create_wallet_transactions_table.php +++ b/src/database/migrations/2020_11_16_202911_create_wallet_transactions_table.php @@ -17,7 +17,7 @@ public function up() $table->id(); $table->unsignedBigInteger('wallet_id'); $table->string('txn')->unique(); - $table->enum('type', ['deposit', 'withdraw', 'bet', 'win'])->nullable(); + $table->enum('type', ['deposit', 'withdraw', 'bet', 'win', 'bonus'])->nullable(); $table->string('intermediary')->nullable(); $table->decimal('amount', 8,2)->default(0); $table->boolean('confirmed')->default(1);