Closed MickaelAmar closed 4 years ago
I realized this can only be done through a ManyToMany relationship. Check this link.
hasMany method doesn't allow mongodb documents to be used with an array of id. Therefore, the related collection should contain 1 document per related id if you want to use the relationship properly.
Hello,
I'm currently trying to build a relationship to retrieve a list of
Ingredients
in myRecommendation
model but it doesn't seem to work and I'm starting to think that my data organization isn't made to suits Laravel features.How can I retrieve all the ingredients models contained in the results array of a Recommendation ? Is a pivot table mandatory at this point ?
Recommendation Model
Ingredient Model
JSON format Recommendation
JSON format Ingredient