2
I have the following scenario in a database:
Tables:
User
- id,
- name
Enterprise
- id
- name
User company
- id_usuario
- id_empresa
- start date
- end date
In this scenario, I need to bring the information from Empresas
that the user is part of and which start date and end in each of them, in the Eloquent
, I made a relationship ManyToMany
, where on the side of Usuario
, have a method empresas()
with belongsToMany('Empresa', 'UsuarioEmpresa')
.
How would you bring these relationship fields?
Companion Evandro’s answer did not suit you, it is correct for the class
Model Usuario
?– novic