In one of my Mongo collections I have a startedAt property on each Document, if I send an AJAX request to get the document directly from Mongo the date comes back as a normal Date object and I can use it as expected, however if I try and query from Laravel, I get a UTCDateTime object that has nothing in it, if I try to print dd it I simply get null printed.
Below is the query in my controller that I send to Mongo:
public function player($accountId)
{
$skip = 0;
$take = 10;
if(isset($_GET['skip'])) $skip = (int)$_GET['skip'];
if(isset($_GET['take'])) $take = (int)$_GET['take'];
$matches = Match::where(['players' => array('$elemMatch' => array('accountId' => $accountId))])
->skip($skip)
->take($take)
->get();
return $matches;
}
Every other field in the collection is accessible in blade, but startedAt always returns null. I've inspected in Mongo Chef and all dates are being saved as Date and they are all in a format like: 2016-08-10T00:15:14.251Z. Why is Laravel unable to process the mongo date, or am I missing something blatantly obvious here?