Skip to content

Commit 69edb92

Browse files
authored
Load related from memory (#249)
* Load related from memory * Apply fixes from StyleCI (#250)
1 parent 35fdb5a commit 69edb92

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Repositories/Repository.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,11 @@ public function resolveRelationships($request): array
521521
$paginator = $this->resource->{$relation}()->take($request->input('relatablePerPage') ?? (static::$defaultRelatablePerPage ?? RestifySearchable::DEFAULT_RELATABLE_PER_PAGE))->get();
522522
}
523523

524-
$withs[$relation] = $paginator->map(fn (Model $item) => [
525-
'attributes' => $item->toArray(),
526-
]);
524+
$withs[$relation] = $paginator instanceof Collection
525+
? $paginator->map(fn (Model $item) => [
526+
'attributes' => $item->toArray(),
527+
])
528+
: $paginator->toArray();
527529
}
528530
}
529531
});

0 commit comments

Comments
 (0)