Skip to content

Commit

Permalink
amount field added to the wallet_transactions table
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket-IN committed May 26, 2022
1 parent 87674de commit f1ef072
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions database/migrations/create_wallet_transactions_table.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ return new class extends Migration
$table->id();
$table->foreignIdFor(Wallet::class);
$table->enum('type', ['credit', 'debit']);
$table->decimal('ob', 10, 2);
$table->decimal('cb', 10, 2);
$table->float('ob', 10, 2);
$table->float('cb', 10, 2);
$table->float('amount', 10, 2);
$table->text('description');
$table->timestamps();
});
Expand Down
2 changes: 2 additions & 0 deletions src/Models/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function deposit(int $amount, string $description)
return $this->transactions()->create([
...$transaction,
'type' => 'credit',
'amount' => $amount,
'cb' => $this->balance,
'description' => $description,
]);
Expand Down Expand Up @@ -82,6 +83,7 @@ public function withdraw(int $amount, string $description, bool $force = false)
return $this->transactions()->create([
...$transaction,
'type' => 'debit',
'amount' => $amount,
'cb' => $this->balance,
'description' => $description,
]);
Expand Down
2 changes: 2 additions & 0 deletions src/Models/WalletTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class WalletTransaction extends Model
use HasFactory;

protected $fillable = [
'amount',
'ob',
'cb',
'description',
Expand All @@ -19,6 +20,7 @@ class WalletTransaction extends Model
protected $casts = [
'ob' => 'float',
'cb' => 'float',
'amount' => 'float',
];

public function wallet()
Expand Down

0 comments on commit f1ef072

Please sign in to comment.