/** * Convert models to plain old php objects. * * @return \ProAI\Datamapper\Support\Collection */ public function toEntity() { $entities = new DatamapperCollection(); foreach ($this->items as $name => $item) { $entities->put($name, $item->toEntity()); } return $entities; }
/** * Convert models to data transfer objects. * * @param string $root * @param array $schema * @param array $transformations * @param string $path * @return \ProAI\Datamapper\Support\Collection */ public function toDataTransferObject(string $root, array $schema, array $transformations, $path = '') { $entities = new DatamapperCollection(); foreach ($this->items as $name => $item) { $entities->put($name, $item->toDataTransferObject($root, $schema, $transformations, $path)); } return $entities; }