[Bug]: Relationship not working if we have multiple relationship with same table #1778
Replies: 7 comments
-
/**
|
Beta Was this translation helpful? Give feedback.
-
So I suspect it's due to how the package creates the joins dynamically. Please confirm which version of the Tables Package, Laravel, Livewire you're using Can you please also share:
Please wrap it in the script tags (three ` marks) I can then try to replicate it on my end and give you some options, or fix any bugs. |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Beta Was this translation helpful? Give feedback.
-
Need the aforementioned to be able to offer guidance on this one... |
Beta Was this translation helpful? Give feedback.
-
Noting that something as simple (assuming a "Sales" model, and a "buyer_id", and "seller_id") with a belongsTo relation for "seller" and "buyer" will work smoothly:
|
Beta Was this translation helpful? Give feedback.
-
I think the problem here is likely how you've structured your table to be honest. Make sure that you select the most appropriate model to base your table on. E.g. If you want to display Sale Items (with a buyer/seller), then base it on Sale Items, don't base it on Sales. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
public function seller()
{
return $this->belongsTo(User::class, 'seller_id')->withTrashed();
}
It returns same value for both columns
How to reproduce the bug
public function seller()
{
return $this->belongsTo(User::class, 'seller_id')->withTrashed();
}
It returns same value for both columns
Package Version
No response
PHP Version
None
Laravel Version
No response
Alpine Version
No response
Theme
None
Notes
No response
Error Message
No response
Beta Was this translation helpful? Give feedback.
All reactions