File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1212use Exception ;
1313use Illuminate \Contracts \Support \Arrayable ;
1414use Illuminate \Database \Eloquent \Collection ;
15+ use Illuminate \Database \Eloquent \Relations \Relation ;
1516use Illuminate \Support \Str ;
1617
1718/**
@@ -119,6 +120,16 @@ private static function getNestedBlocksForData(
119120
120121 $ block ->setRelation ('children ' , self ::getChildren ($ children ));
121122
123+ foreach ($ data ['browsers ' ] as $ browserName => $ browserItems ) {
124+ $ browserData = collect ();
125+ foreach ($ browserItems as $ browserItem ) {
126+ $ className = Relation::getMorphedModel ($ browserItem ['endpointType ' ]) ?? $ browserItem ['endpointType ' ];
127+ $ browserData ->push ((new $ className ())->find ($ browserItem ['id ' ]));
128+ }
129+
130+ $ block ->setRelatedCache ($ browserName , $ browserData );
131+ }
132+
122133 $ block ->medias = self ::getMedias ($ data );
123134
124135 $ class ->setRenderData (
Original file line number Diff line number Diff line change @@ -125,4 +125,9 @@ public function clearAllRelated(): void
125125 {
126126 $ this ->relatedItems ()->delete ();
127127 }
128+
129+ public function setRelatedCache ($ browser , $ items ): void
130+ {
131+ $ this ->relatedCache [$ browser ] = $ items ;
132+ }
128133}
You can’t perform that action at this time.
0 commit comments