File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 20
20
use Bavix \Wallet \Traits \HasGift ;
21
21
use DateTimeInterface ;
22
22
use Illuminate \Database \Eloquent \Model ;
23
+ use Illuminate \Database \Eloquent \Relations \HasMany ;
23
24
use Illuminate \Database \Eloquent \Relations \MorphTo ;
24
25
use Illuminate \Database \RecordsNotFoundException ;
25
26
use Illuminate \Support \Str ;
@@ -162,4 +163,14 @@ protected function initializeMorphOneWallet(): void
162
163
{
163
164
$ this ->uuid = app (UuidFactoryServiceInterface::class)->uuid4 ();
164
165
}
166
+
167
+ /**
168
+ * returns all the receiving transfers to this wallet.
169
+ *
170
+ * @return HasMany<Transfer>
171
+ */
172
+ public function receivedTransfers (): HasMany
173
+ {
174
+ return $ this ->hasMany (config ('wallet.transfer.model ' , Transfer::class), 'to_id ' );
175
+ }
165
176
}
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ public function testBlock(): void
35
35
);
36
36
37
37
self ::assertSame (1 , $ user2 ->transfers ()->count ());
38
+ self ::assertSame (2 , $ user2 ->wallet ->receivedTransfers ()->count ());
39
+ self ::assertSame (1 , $ user1 ->wallet ->receivedTransfers ()->count ());
38
40
self ::assertSame (2 , $ user1 ->transfers ()->count ());
39
41
self ::assertSame (3 , $ user2 ->transactions ()->count ());
40
42
self ::assertSame (4 , $ user1 ->transactions ()->count ());
You can’t perform that action at this time.
0 commit comments