Skip to content

Commit 30bacfc

Browse files
authored
Add payments relation on wallet
This adds functionality to query the database for transfers in the other direction, payments. Lookup what transfers happened from another wallet to this one. Signed-off-by: George Klincarski <[email protected]>
1 parent 923f182 commit 30bacfc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/Traits/HasWallet.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,18 @@ public function transfers(): HasMany
227227
->hasMany(config('wallet.transfer.model', Transfer::class), 'from_id')
228228
;
229229
}
230+
231+
/**
232+
* returns all the receiving transfers to this wallet.
233+
*
234+
* @return HasMany<Transfer>
235+
*/
236+
public function payments(): HasMany
237+
{
238+
/** @var Wallet $this */
239+
return app(CastServiceInterface::class)
240+
->getWallet($this, false)
241+
->hasMany(config('wallet.transfer.model', Transfer::class), 'to_id')
242+
;
243+
}
230244
}

0 commit comments

Comments
 (0)