/** * {@inheritdoc} */ public function hydrate(AbstractEntity $entity, AbstractProperty $property) { $value = isset($this->entries[$entity->getId()]) ? $this->entries[$entity->getId()] : array(); $value = $this->relationshipCollection->createChildCollection($entries); $entity->setAttribute($property->getName(), $value); return $value; }
/** * {@inheritdoc} */ public function hydrate(AbstractEntity $entity, AbstractProperty $property) { $value = $entity->getAttribute($property->getIdentifier()); $value = $value ? explode("|", $value) : null; $entity->setAttribute($property->getName(), $value); return $value; }
/** * {@inheritdoc} */ public function hydrate(AbstractEntity $entity, AbstractProperty $property) { $value = $entity->getAttribute($property->getIdentifier()); $value = $value ? Carbon::createFromFormat('U', $value) : null; $entity->setAttribute($property->getName(), $value); return $value; }
public function dehydrate(AbstractEntity $entity, AbstractProperty $property) { $file = $entity->getAttribute($property->getName()); return $file ? '{filedir_' . $file->upload_location_id . '}' . $file->file_name : null; }
/** * {@inheritdoc} */ public function hydrate(AbstractEntity $entity, AbstractProperty $property) { $value = isset($this->sortedRows[$entity->getId()][$property->getId()]) ? $this->sortedRows[$entity->getId()][$property->getId()] : new GridRowCollection(); $entity->setAttribute($property->getName(), $value); return $value; }
/** * {@inheritdoc} */ public function dehydrate(AbstractEntity $entity, AbstractProperty $property) { $assets = $entity->getAttribute($property->getName()); // drop old relations $this->db->table('assets_selections')->where($property->getPrefix() . '_id', $property->getId())->where($entity->getPrefix() . '_id', $entity->getId())->delete(); if ($assets) { foreach ($assets as $asset) { /* $this->db->table('assets_selections') ->insert([ $property->getPrefix().'_id' => $property->getId(), $entity->getPrefix().'_id' => $entity->getId(), $asset->file_id, ] */ } return '1'; } }
/** * {@inheritdoc} */ public function hydrate(AbstractEntity $entity, AbstractProperty $property) { $value = $this->parse($entity->getAttribute($property->getIdentifier())); $entity->setAttribute($property->getName(), $value); return $value; }
/** * {@inheritdoc} */ public function toArray() { $array = parent::toArray(); foreach ($array as &$row) { if (method_exists($row, 'toArray')) { $row = $row->toArray(); } } return $array; }
/** * {@inheritdoc} */ public function attributesToArray() { $attributes = parent::attributesToArray(); foreach (array('entry_date', 'edit_date', 'expiration_date', 'comment_expiration_date', 'recent_comment_date') as $key) { if (isset($attributes[$key]) && $attributes[$key] instanceof Carbon) { $attributes[$key] = (string) $attributes[$key]; } } return $attributes; }