Did you find any solutions for this, now I'm standing in same problem. If you have a solutions means please share
Laravel Eloquent Models with embedded MongoDB documents
Hi there,
I am struggling to understand how MongoDB database structure can be used within Laravel.
I have one collection with documents of "patients", and each document embeds sub-documents on multiple levels in arrays like "diagnosis", "subscriptions" and other sub-documents.
In this case, am I supposed to create different eloquent models for each sub-document group? Or just use everything with my default "Patient" model? Which is the most optimal method that would help me to look up associated prescriptions, diagnosis and other patient-related information for every patient?
an example of how my database structure will look like:
{
_id: "joe",
name: "Joe"
diagnosis: [
{
name: "asthma",
prescriptions: [
{
name: "presc-1"
},
{
name: "presc-2"
},
{
name: "presc-3"
}]
},
{
name: "back pain",
prescriptions: [
{
name: "presc-1"
},
{
name: "presc-2"
},
{
name: "presc-3"
}]
}]
}
Please or to participate in this conversation.