Skip to content

Commit 53e1ed9

Browse files
authored
Update Transfer Model Morph
Transfer model has `from` and `to` relationships that actually morphed in the database. This change reflects that on the model too. Signed-off-by: George Klincarski <[email protected]>
1 parent b7712f7 commit 53e1ed9

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Models/Transfer.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Database\Eloquent\Relations\BelongsTo;
9+
use Illuminate\Database\Eloquent\Relations\MorphTo;
910
use function config;
1011

1112
/**
@@ -79,17 +80,17 @@ public function getTable(): string
7980
/**
8081
* @return BelongsTo<Wallet, self>
8182
*/
82-
public function from(): BelongsTo
83+
public function from(): MorphTo
8384
{
84-
return $this->belongsTo(config('wallet.wallet.model', Wallet::class), 'from_id');
85+
return $this->morphTo();
8586
}
8687

8788
/**
8889
* @return BelongsTo<Wallet, self>
8990
*/
90-
public function to(): BelongsTo
91+
public function to(): MorphTo
9192
{
92-
return $this->belongsTo(config('wallet.wallet.model', Wallet::class), 'to_id');
93+
return $this->morphTo();
9394
}
9495

9596
/**

0 commit comments

Comments
 (0)