Answer the question
In order to leave comments, you need to log in
Laravel eloquent - how to create a relationship through two tables with a return?
There are tables and corresponding models:
wallets (Wallet)
id
...
id
transfer_id
wallet_id
transaction_id
from_wallet_id
to_wallet_id
...
id
.....
public function transfers()
{
return $this->belongsToMany(Transfer::class, 'transfer_wallets', 'wallet_id', 'id')->with(['senderWallet', 'recipientWallet','transaction']);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question