We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb0765e commit 22f3a19Copy full SHA for 22f3a19
src/Traits/HasWallets.php
@@ -26,6 +26,11 @@ trait HasWallets
26
*/
27
private $_wallets = [];
28
29
+ /**
30
+ * @var bool
31
+ */
32
+ private $_loadedWallets = false;
33
+
34
/**
35
* Get wallet by slug
36
*
@@ -43,11 +48,8 @@ trait HasWallets
43
48
44
49
public function getWallet(string $slug): ?WalletModel
45
50
{
46
- if (\array_key_exists($slug, $this->_wallets)) {
47
- return $this->_wallets[$slug];
- }
-
- if ($this->relationLoaded('wallets')) {
51
+ if (!$this->_loadedWallets && $this->relationLoaded('wallets')) {
52
+ $this->_loadedWallets = true;
53
$wallets = $this->getRelation('wallets');
54
foreach ($wallets as $wallet) {
55
$this->_wallets[$wallet->slug] = $wallet;
0 commit comments