Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Transfer Model #858

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/Models/Transfer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use function config;

/**
Expand Down Expand Up @@ -79,32 +80,32 @@ public function getTable(): string
/**
* @return BelongsTo<Wallet, self>
*/
public function from(): BelongsTo
public function from(): MorphTo
rez1dent3 marked this conversation as resolved.
Show resolved Hide resolved
{
return $this->belongsTo(Wallet::class, 'from_id');
return $this->morphTo();
}

/**
* @return BelongsTo<Wallet, self>
*/
public function to(): BelongsTo
public function to(): MorphTo
rez1dent3 marked this conversation as resolved.
Show resolved Hide resolved
{
return $this->belongsTo(Wallet::class, 'to_id');
return $this->morphTo();
}

/**
* @return BelongsTo<Transaction, self>
*/
public function deposit(): BelongsTo
{
return $this->belongsTo(Transaction::class, 'deposit_id');
return $this->belongsTo(config('wallet.transaction.model', Transaction::class), 'deposit_id');
rez1dent3 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* @return BelongsTo<Transaction, self>
*/
public function withdraw(): BelongsTo
{
return $this->belongsTo(Transaction::class, 'withdraw_id');
return $this->belongsTo(config('wallet.transaction.model', Transaction::class), 'withdraw_id');
rez1dent3 marked this conversation as resolved.
Show resolved Hide resolved
}
}