Unable To Figure Out A Belongs_To Relation With Intermediary Table

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?

I feel like you should be able to do this using through. What went wrong specifically when you tried that?

The issue is that “through” requires a model to go “through”. My goal is to eventually make this dynamic (since the relation table names are fixed and I can dynamically determine those), so I’d like to avoid having to create an additional model for the relation table.