I have the following scenario in a database:
Tables:
User
- id,
- name
Company
- id
- name
UserCompany
- userid
- business_id
- start_date
- data_termino
In this scenario, I need to bring the information of the Empresas
that the user is part of and start date and end in each of them, in Eloquent
I made a ManyToMany
relationship, where on the Usuario
side, I have a empresas()
method with belongsToMany('Empresa', 'UsuarioEmpresa')
.
How would you bring these fields of the relationship?