Skip to content

Commit 39de5d3

Browse files
authored
Merge pull request #79 from bavix/relations
#78 Relations
2 parents 2e43659 + 4913c76 commit 39de5d3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

changelog.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [3.1.4] - 2019-08-03
10+
### Added
11+
- Add support `barryvdh/laravel-ide-helper`
12+
13+
### Fixed
14+
- Fixed receiving `wallets.transfers` relationship @imhuso
15+
916
## [3.1.3] - 2019-07-31
1017
### Added
1118
- Add support SQLite on command `RefreshBalance`
@@ -369,7 +376,8 @@ The operation is now executed in the transaction and updates the new `refund` fi
369376
- Exceptions: AmountInvalid, BalanceIsEmpty.
370377
- Models: Transfer, Transaction.
371378

372-
[Unreleased]: https://github.com/bavix/laravel-wallet/compare/3.1.3...HEAD
379+
[Unreleased]: https://github.com/bavix/laravel-wallet/compare/3.1.4...HEAD
380+
[3.1.4]: https://github.com/bavix/laravel-wallet/compare/3.1.3...3.1.4
373381
[3.1.3]: https://github.com/bavix/laravel-wallet/compare/3.1.2...3.1.3
374382
[3.1.2]: https://github.com/bavix/laravel-wallet/compare/3.1.1...3.1.2
375383
[3.1.1]: https://github.com/bavix/laravel-wallet/compare/3.1.0...3.1.1

src/Services/WalletService.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ public function checkAmount(int $amount): void
6868

6969
/**
7070
* @param Wallet $object
71+
* @param bool $autoSave
7172
* @return WalletModel
7273
*/
73-
public function getWallet(Wallet $object): WalletModel
74+
public function getWallet(Wallet $object, bool $autoSave = true): WalletModel
7475
{
7576
/**
7677
* @var WalletModel $wallet
@@ -84,7 +85,10 @@ public function getWallet(Wallet $object): WalletModel
8485
$wallet = $object->wallet;
8586
}
8687

87-
$wallet->exists or $wallet->save();
88+
if ($autoSave) {
89+
$wallet->exists or $wallet->save();
90+
}
91+
8892
return $wallet;
8993
}
9094

src/Traits/HasWallet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function forceTransfer(Wallet $wallet, int $amount, ?array $meta = null):
197197
public function transfers(): MorphMany
198198
{
199199
return app(WalletService::class)
200-
->getWallet($this)
200+
->getWallet($this, false)
201201
->morphMany(config('wallet.transfer.model'), 'from');
202202
}
203203

0 commit comments

Comments
 (0)