Skip to content

Commit

Permalink
Fixing transactions creation with default wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
depsimon committed Feb 22, 2018
1 parent 64169a2 commit a3c4ace
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/HasWallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function deposit($amount, $type = 'deposit', $meta = [])
$this->wallet->balance += $amount;
$this->save();

$this->transactions()
$this->wallet->transactions()
->create([
'amount' => $amount,
'hash' => uniqid('lwch_'),
Expand All @@ -75,7 +75,7 @@ public function withdraw($amount, $type = 'withdraw', $meta = [], $shouldAccept
$this->save();
}

$this->transactions()
$this->wallet->transactions()
->create([
'amount' => $amount,
'hash' => uniqid('lwch_'),
Expand Down Expand Up @@ -104,11 +104,11 @@ public function forceWithdraw($amount, $type = 'withdraw', $meta = [])
*/
public function actualBalance()
{
$credits = $this->transactions()
$credits = $this->wallet->transactions()
->whereIn('type', ['deposit', 'refund'])
->sum('amount');

$debits = $this->transactions()
$debits = $this->wallet->transactions()
->whereIn('type', ['withdraw', 'payout'])
->sum('amount');

Expand Down

0 comments on commit a3c4ace

Please sign in to comment.