diff --git a/resources/views/components/page-blocks.blade.php b/resources/views/components/page-blocks.blade.php index fddfba3..fe2a37d 100644 --- a/resources/views/components/page-blocks.blade.php +++ b/resources/views/components/page-blocks.blade.php @@ -1,14 +1,27 @@ +@aware(['page']) @props(['blocks' => []]) +@php + $groups = \Z3d0X\FilamentFabricator\Helpers::arrayRefsGroupBy($blocks, 'type'); + + foreach ($groups as $blockType => &$group) { + /** + * @var class-string<\Z3d0X\FilamentFabricator\PageBlocks\PageBlock> $blockClass + */ + $blockClass = FilamentFabricator::getPageBlockFromName($blockType); + + if (!empty($blockClass)) { + $blockClass::preloadRelatedData($page, $group); + } + } +@endphp + @foreach ($blocks as $blockData) @php - $pageBlock = \Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getPageBlockFromName($blockData['type']) + $pageBlock = \Z3d0X\FilamentFabricator\Facades\FilamentFabricator::getPageBlockFromName($blockData['type']); @endphp @isset($pageBlock) - + @endisset @endforeach diff --git a/src/Helpers.php b/src/Helpers.php new file mode 100644 index 0000000..cca0ee2 --- /dev/null +++ b/src/Helpers.php @@ -0,0 +1,23 @@ +