Esempio n. 1
0
 protected function typeCastForSet($attrName, $value)
 {
     switch ($this->getAttribute($attrName)->type()) {
         case 'datetime':
             if ($value instanceof MongoDate) {
                 list($u, $s) = explode(" ", (string) $value);
                 $u = (double) $u;
                 $s = (int) $s;
                 return Carbon::createFromFormat('U.u', sprintf('%.f', $s + $u));
             }
             break;
         case 'mongoId':
             return $value;
     }
     return parent::typeCastForSet($attrName, $value);
 }