Skip to content

Commit

Permalink
Add payments relation on wallet
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
gkmk authored Jan 30, 2024
1 parent 923f182 commit 30bacfc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Traits/HasWallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,18 @@ public function transfers(): HasMany
->hasMany(config('wallet.transfer.model', Transfer::class), 'from_id')
;
}

/**
* returns all the receiving transfers to this wallet.
*
* @return HasMany<Transfer>
*/
public function payments(): HasMany
{
/** @var Wallet $this */
return app(CastServiceInterface::class)
->getWallet($this, false)
->hasMany(config('wallet.transfer.model', Transfer::class), 'to_id')
;
}
}

0 comments on commit 30bacfc

Please sign in to comment.