/** * Get property simple value by name. * * @param string $key * * @return mixed|Collection */ public function getValue($key) { $value = $this->getPropertyValue($key); $property = $this->getProperties()->get($key); if ($value instanceof Collection) { /* @var MultipleCollection $collection * @var Collection $value */ $collection = $this->entity->relationLoaded($key) ? $this->entity->getRelation($key) : null; if ($collection === null) { $collection = new MultipleCollection($this, $property); } $collection->setValues($value->map(function (Value $value) { return $value->getAttributeValue('value'); })); return $collection; } elseif ($value instanceof Value) { return $value->getAttributeValue('value'); } }