I want to save a date, in the Mongo date format, in a nested array. I know how to do this with first level attributes, by using Eloquent date mutator, but I have no idea if it's possible with nested attributes.
The data structure looks like that :
things: [
{
id: "53fe00511bbed96e0a0041a9",
date: "2014-08-27 17:59:13",
...
}
]
This is not an embedded relationship. This is more a kind of many to many relationship with pivot data.
I have tried to save a string and an instance of Carbon as a date but they are saved, respectively, as a string and an array and the getter return a string and an array.
I currently have to use mutator functions to accomplish something like this. The model has a couple of methods that make life easier to do this however
$this->asDateTime(string)
and
$this->fromDateTime(string)
+1 for being able to specify nested properties as dates like root level date properties can be.
could you specify i have the same problem
Most helpful comment
I currently have to use mutator functions to accomplish something like this. The model has a couple of methods that make life easier to do this however
+1 for being able to specify nested properties as dates like root level date properties can be.