I have a table avaliacaos and a table servicos and in avaliacaos I want to reffer to multiple services. I've followed the docs and created a Many to Many relationship and used the Multiple Select for selecting the services(servicos) I want to evaluate(avaliacaos). I've used the following code on my Avaliacaos Model:
public function servico(){
return $this->belongsToMany(Servicos::class,'avaliacaos_servicos');
}
I've created the pivot table avaliacaos_servicos on my database:

But when I add the avaliacao trhough the BREAD, It returns this:

Here's the structure of my avaliacaos table:

I want to add a avaliacao item and select Multiple Servicos. Therefore, the pivot table should associate the servico with the avaliacao.
What did I do wrong? How can I fix this? Am I supposed to do anything else I haven't done in order to achieve the result I need?
I've seen a similar issue, https://github.com/the-control-group/voyager/issues/354 . Not fixed still... Anybody has any idea of what's going on? Anybody did created a Many to Many relationship following only the steps of the docs, just like me but got the expected result? What did you do different? Thank you very much.
This is not an issue with Voyager. Please refer to Laravel documentation on how to handle relationships. Many-to-many relationships only need the pivot/intermediary table. There should not be a reference from the servico table
Ok, but if I don't put servico on my BREAD table, how will this field appear in my view? Should I override manually all my views which have Many To Many relationships?
Apologies, I misunderstood.
Voyager does not currently support Many-to-Many relations in it's views, though I believe someone is currently working on that. My instructions above were for using Laravel functionality to build the relation.
As a workaround, you could add BREAD to the pivot table, and configure fields using one-to-many relations there.
Hi, did you find any approach that could fulfill this functionality, I'm now going through the same situation.
Best regards,
Has anyone come up with a solution to this problem as yet?
error:----SQLSTATE[42S22]: Column not found: 1054 Unknown column 'track_cd.teck_list_id' in 'field list' (SQL: select id, name, track_cd.teck_list_id as pivot_teck_list_id, track_cd.cd_id as pivot_cd_id from cds inner join track_cd on cds.id = track_cd.cd_id where track_cd.teck_list_id in (7, 6, 5, 4, 3, 2, 1))
This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.
Most helpful comment
Hi, did you find any approach that could fulfill this functionality, I'm now going through the same situation.
Best regards,