diff --git a/src/Helpers/BlockRenderer.php b/src/Helpers/BlockRenderer.php index 7527043b6..656aeafa4 100644 --- a/src/Helpers/BlockRenderer.php +++ b/src/Helpers/BlockRenderer.php @@ -12,6 +12,7 @@ use Exception; use Illuminate\Contracts\Support\Arrayable; use Illuminate\Database\Eloquent\Collection; +use Illuminate\Database\Eloquent\Relations\Relation; use Illuminate\Support\Str; /** @@ -119,6 +120,16 @@ private static function getNestedBlocksForData( $block->setRelation('children', self::getChildren($children)); + foreach ($data['browsers'] as $browserName => $browserItems) { + $browserData = collect(); + foreach ($browserItems as $browserItem) { + $className = Relation::getMorphedModel($browserItem['endpointType']) ?? $browserItem['endpointType']; + $browserData->push((new $className())->find($browserItem['id'])); + } + + $block->setRelatedCache($browserName, $browserData); + } + $block->medias = self::getMedias($data); $class->setRenderData( diff --git a/src/Models/Behaviors/HasRelated.php b/src/Models/Behaviors/HasRelated.php index 3996648f3..4a728ea0e 100644 --- a/src/Models/Behaviors/HasRelated.php +++ b/src/Models/Behaviors/HasRelated.php @@ -125,4 +125,9 @@ public function clearAllRelated(): void { $this->relatedItems()->delete(); } + + public function setRelatedCache($browser, $items): void + { + $this->relatedCache[$browser] = $items; + } }