Skip to content

Commit

Permalink
fix: avoid edge cases with eager loading (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 authored Dec 12, 2023
1 parent ea3231b commit 9d70b61
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/LoadActorVoteRelationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public static function sumRelation($controller, $data): void
} elseif ($data instanceof Collection) {
$loadable = (new Post())->newCollection($data->map(function ($model) {
return $model instanceof Discussion ? ($model->mostRelevantPost ?? $model->firstPost) : $model;
}));
})->filter());
} elseif ($data instanceof Post) {
$loadable = $data->newCollection([$data]);
}

if ($loadable) {
if ($loadable && $loadable instanceof Collection) {
$loadable->loadSum('actualvotes', 'value');
}
}
Expand Down

0 comments on commit 9d70b61

Please sign in to comment.