Skip to content

Commit f1ef072

Browse files
committed
amount field added to the wallet_transactions table
1 parent 87674de commit f1ef072

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

database/migrations/create_wallet_transactions_table.php.stub

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ return new class extends Migration
1313
$table->id();
1414
$table->foreignIdFor(Wallet::class);
1515
$table->enum('type', ['credit', 'debit']);
16-
$table->decimal('ob', 10, 2);
17-
$table->decimal('cb', 10, 2);
16+
$table->float('ob', 10, 2);
17+
$table->float('cb', 10, 2);
18+
$table->float('amount', 10, 2);
1819
$table->text('description');
1920
$table->timestamps();
2021
});

src/Models/Wallet.php

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function deposit(int $amount, string $description)
4949
return $this->transactions()->create([
5050
...$transaction,
5151
'type' => 'credit',
52+
'amount' => $amount,
5253
'cb' => $this->balance,
5354
'description' => $description,
5455
]);
@@ -82,6 +83,7 @@ public function withdraw(int $amount, string $description, bool $force = false)
8283
return $this->transactions()->create([
8384
...$transaction,
8485
'type' => 'debit',
86+
'amount' => $amount,
8587
'cb' => $this->balance,
8688
'description' => $description,
8789
]);

src/Models/WalletTransaction.php

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class WalletTransaction extends Model
1010
use HasFactory;
1111

1212
protected $fillable = [
13+
'amount',
1314
'ob',
1415
'cb',
1516
'description',
@@ -19,6 +20,7 @@ class WalletTransaction extends Model
1920
protected $casts = [
2021
'ob' => 'float',
2122
'cb' => 'float',
23+
'amount' => 'float',
2224
];
2325

2426
public function wallet()

0 commit comments

Comments
 (0)