Skip to content

Commit

Permalink
Update DataCompiler.php
Browse files Browse the repository at this point in the history
  • Loading branch information
pabloelcolombiano authored Aug 1, 2020
1 parent eca204f commit 44de95f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Factory/DataCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ public function getCompiledTemplateData(): array
/** @var BaseFactory $dataFactory */
$dataFactory = $data;
if ($association instanceof HasOne || $association instanceof BelongsTo) {
$compiledTemplateData[$propertyName] = $dataFactory->toArray()[0];

// toOne associated data must be singular when saved
$propertyName = Inflector::singularize($propertyName);

$compiledTemplateData[$propertyName] = $dataFactory->toArray()[0];
} else {
$compiledTemplateData[$propertyName] = $dataFactory->toArray();
}
Expand Down Expand Up @@ -215,4 +219,4 @@ public function getFactory(): BaseFactory
{
return $this->factory;
}
}
}

0 comments on commit 44de95f

Please sign in to comment.