I’ll try to summarize as best as I can:
I am creating a couple of models to interact with a SugarCRM database. Relationships between objects are placed in to an intermediary table - even if they’re 1:1 or M:1.
So for example, an order belongs to a single account, but the relationship between the two is defined in an "OrderToAccount" table.
Order Table:
PK: order_id
Account Table:
PK: account_id
OrderToAccount Table:
order_id, account_id
Now while this is pretty much exactly a many to many setup, I know for a fact that there will ever only be a single Account per Order.
Although I have been able to easily set up a MANY_MANY relation based on this model, I’d like to access the account via $order->account, not $order->account[0]. I’ve struggled to figure out how I can set up a BELONGS_TO relation using an intermediary join table - without creating a model for the join table. I’ve tried using a bunch of different techniques (including using through) but have basically hit a wall.
Any recommendations?