Commit 6ec9573b authored by Jens Segers's avatar Jens Segers

Manual merge of #487

parent db0c9525
...@@ -336,6 +336,15 @@ return; ...@@ -336,6 +336,15 @@ return;
} }
} }
// Convert dot-notation dates.
foreach ($this->getDates() as $key)
{
if (str_contains($key, '.') and array_has($attributes, $key))
{
array_set($attributes, $key, (string) $this->asDateTime(array_get($attributes, $key)));
}
}
return $attributes; return $attributes;
} }
......
...@@ -402,6 +402,10 @@ class ModelTest extends TestCase { ...@@ -402,6 +402,10 @@ class ModelTest extends TestCase {
$user->setAttribute('entry.date', new DateTime); $user->setAttribute('entry.date', new DateTime);
$this->assertInstanceOf('Carbon\Carbon', $user->getAttribute('entry.date')); $this->assertInstanceOf('Carbon\Carbon', $user->getAttribute('entry.date'));
$data = $user->toArray();
$this->assertNotInstanceOf('MongoDate', $data['entry']['date']);
$this->assertEquals((string) $user->getAttribute('entry.date')->format('Y-m-d H:i:s'), $data['entry']['date']);
} }
public function testIdAttribute() public function testIdAttribute()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment