1: <?php
2:
3: 4: 5: 6: 7: 8:
9:
10: namespace rsanchez\Deep\Hydrator;
11:
12: use Illuminate\Database\Eloquent\Model;
13: use rsanchez\Deep\Model\AbstractProperty;
14: use rsanchez\Deep\Model\AbstractEntity;
15: use rsanchez\Deep\Hydrator\AbstractHydrator;
16: use Carbon\Carbon;
17:
18: 19: 20:
21: class DateHydrator extends AbstractHydrator
22: {
23: 24: 25:
26: public function hydrate(AbstractEntity $entity, AbstractProperty $property)
27: {
28: $value = $entity->getAttribute($property->getIdentifier());
29:
30: $value = $value ? Carbon::createFromFormat('U', $value) : null;
31:
32: $entity->setAttribute($property->getName(), $value);
33:
34: return $value;
35: }
36: }
37: