perhaps have a look at sushi. This is an eloquent driver that can be loaded with data as an array.
Is it possible to have hasMany in memory?
I have an Eloquent model that uses MongoDB as the backend. This model stores information on PBXes and part of the model is an array of trunk information. Today I am treating the trunk information as an array and that is becoming a bit of a pain as I am finding more needs to validate and insure that the trunk information has some specific attributes.
I then started to think that it would be better if I created a trunk model that would manage and insure that the attributes were present or set rational default values. This would make the PBX model have a hasMany relationship with the trunk model.
But here is the rub. I don't want to have the trunk model be another collection in MongoDB. It is already a subset of the PBX model / collection. What I am really looking for (ideally) is if when reading a PBX record that the trunk array could be "de-serialized" into an in-memory array of trunk objects (via the model) and then when the PBX model is saved that the the trunk objects would then be "serialized" back into the PBX model to be saved.
It would be great if it would be automatic like this, but I suspect that I would need to write some code around this process. I just don't know any of the innards of Eloquent to know how I could intercept the calls and make something like this work.
I have only been using Laravel for a few weeks and still learning things every day. If anyone has any ideas, I would love to hear them.
Thanks, Gerard.
Please or to participate in this conversation.