How can I get the pivot table data using Laravel Eloquent?
I need to know which setor_id
of users and group_id
linked
If I understand, I think this is what you need. I left in standard form and also in eloquent
select ug.setor_id, setors.nome, ug.group_id, groups.descricao
from users_groups_has_users as ug
inner join groups on groups.id = ug.group_id
inner join setors on setors.id = ug.setors_id
$query = DB::table('users_groups_has_users')->join('groups', 'join groups on groups.id', '=', 'users_groups_has_users.group_id')->join('setors', 'join setors on setors.id', '=', 'users_groups_has_users.setor_id')
->select('ug.setor_id', 'setors.nome', 'ug.group_id', 'groups.descricao')->get()