What is the exact error you get? Can you give us the share link from the laravel debug screen?
Mar 16, 2023
3
Level 1
Eloquent relationship
I have 2 relationship as follow:
public function method()
{
return $this->belongsTo(Method::class, 'method_id', 'id') ;
}
public function transferee()
{
return $this->belongsTo(Transferee::class, 'transferee_id', 'id') ;
}
However, only one relationship works (method) the other doesn't work though its table structure, model... are the same with the other (method) My mistake, I changed the foreign key of transferee() relationship to 'method_id' and it work like a charm.
Please help me to explain this situation.
Thank you so much
Level 1
Problem was solved. The error caused by one Customer record which Tranferee_id is null.
Please or to participate in this conversation.