Skip to content

Commit

Permalink
[9.x] Prevent test issues with relations with the $touches property (…
Browse files Browse the repository at this point in the history
…#45118)

* #45064 - Added function to remove empty relationships that were causing issues with touched relationships on tests

* #45064 - Fixed code style issue

* formatting

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
WendellAdriel and taylorotwell authored Nov 28, 2022
1 parent 0ac9f0d commit 7d88268
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Eloquent/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ protected function store(Collection $results)

$model->save();

foreach ($model->getRelations() as $name => $items) {
if ($items->isEmpty()) {
$model->unsetRelation($name);
}
}

$this->createChildren($model);
});
}
Expand Down

0 comments on commit 7d88268

Please sign in to comment.