0
I have 3 tables: contratos, contratos_empresas and empresas
In the system there is a form for registration of contracts, in this form there is a select Multiple (that allows to select several companies at the same time), the <options> this select comes from the table empresas, and how several companies can be selected, the contratos does not have a field loan and this select data is saved in the table contratos_empresas saving the contrado_id and the loan.
There’s already a relationship like hasMany in the contract model, what I would like to do is to select the companies, from the table contratos_empresas, through the contract, also select companies where the id is equal to those of the contrato_empresas, it is possible to do this?
Summary for better understanding:
contrato_empresas belongs so much to contratos as empresas, and is linked to these tables via the fields: contrato_id and loan
You want to select only companies that have contracts. That’s it?
– SpockWayne
The contracts that have companies, within hasMany (contratos_empresas) of the contract, I do not know if it was very clear
– Thiago