File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -42,4 +42,21 @@ public function wallet(): MorphOne
4242 })
4343 ;
4444 }
45+
46+ public function getWalletAttribute (): ?WalletModel
47+ {
48+ $ wallet = $ this ->getRelationValue ('wallet ' );
49+ if ($ wallet === null ) {
50+ return null ;
51+ }
52+
53+ assert ($ wallet instanceof WalletModel);
54+
55+ if (!$ wallet ->relationLoaded ('holder ' )) {
56+ $ holder = app (CastServiceInterface::class)->getHolder ($ this );
57+ $ wallet ->setRelation ('holder ' , $ holder );
58+ }
59+
60+ return $ wallet ;
61+ }
4562}
Original file line number Diff line number Diff line change @@ -35,8 +35,7 @@ public function testUuidDuplicate(): void
3535 $ balances = [];
3636 foreach ($ buyers as $ buyer ) {
3737 self ::assertTrue ($ buyer ->relationLoaded ('wallet ' ));
38- // self::assertTrue($buyer->wallet->relationLoaded('holder'));
39- // fixme: I did not find a way to load the buyer, maybe someday I will get there.
38+ self ::assertTrue ($ buyer ->wallet ->relationLoaded ('holder ' ));
4039
4140 $ uuids [] = $ buyer ->wallet ->uuid ;
4241 $ balances [] = $ buyer ->wallet ->balanceInt ;
You can’t perform that action at this time.
0 commit comments