I have a main model which is named Tour
and I have another model OptionPrices
. How can I establish a relationship based on this conditions
option_prices
table
+-------+---------+----------+
| id | channel | optionid |
+-------+---------+----------+
| 12531 | 9278 | 10003 |
| 12533 | 5408 | 10003 |
| 12530 | 5501 | 10003 |
| 12529 | 3862 | 10003 |
| 12535 | 9225 | 10003 |
| 12536 | 6640 | 10003 |
| 12534 | 6111 | 10003 |
| 12532 | 5235 | 10003 |
| 12492 | 3862 | 10002 |
| 12491 | 6640 | 10002 |
+-------+---------+----------+
A tour can have many option_prices
but its not using the id
, it is based on the optionid
column BUT it must be grouped by so it will became one optionid
I am planning to use a pivot table but the problem is I think it will attach multiple option_prices
and when I am getting the OptionPrices
relation, it will result in multi query?
What would be the best approach for this one? Thanks in advance.