Skip to content

Commit 3bd4355

Browse files
committed
Eager load all the related items at once
1 parent a9a1d52 commit 3bd4355

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

src/Repositories/Behaviors/HandleRevisions.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,8 @@ public function hydrateRelatedBrowsers(TwillModelContract $object, array $fields
157157

158158
foreach ($relatedBrowsers as $browser) {
159159
$browserField = $fields['browsers'][$browser['browserName']] ?? [];
160-
161160
$position = 1;
162161
foreach ($browserField as $values) {
163-
164162
$relatedBrowserItems->push(new RelatedItem([
165163
'subject_id' => $object->getKey(),
166164
'subject_type' => $object->getMorphClass(),

src/Repositories/BlockRepository.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function hydrate(TwillModelContract $model, array $fields): TwillModelCon
4747
);
4848

4949
$model->setRelation('relatedItems', $relatedItems);
50+
$model->loadMissing('relatedItems.related');
5051

5152
return parent::hydrate($model, $fields);
5253
}

0 commit comments

Comments
 (0)