Skip to content

Commit

Permalink
Fixed bug on associations removal
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrerolland committed Sep 11, 2018
1 parent a37421b commit 9770924
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Builder/EntityBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,17 @@ private function mergeCollection(
*/
private function removeItemsNotInRequest($entityValues, array $requestValues)
{
if (!$entityValues) {
if (!$entityValues || ($entityValues instanceof Collection && $entityValues->count() === 0)) {
return null;
}

$entityClass = $entityValues instanceof Collection ? get_class($entityValues->current()) :
is_array($entityValues) ? get_class(current($entityValues)) : null;
if ($entityValues instanceof Collection) {
$entityClass = get_class($entityValues->first());
} elseif (is_array($entityValues)) {
$entityClass = get_class($entityValues[0]);
} else {
$entityClass = null;
}

if (!$entityClass) {
return null;
Expand Down

0 comments on commit 9770924

Please sign in to comment.