laravel-cms
laravel-cms copied to clipboard
Please Address the n + 1 query issues in rendering blocks and widgets
Please the below code in Models/Blade.php. To eliminate n + 1 querying situations, you could use some get request before running the loop inside renderBlocks function and remove self::find($blockID) part for each Block.
`public static function renderBlocks($string) {
....
foreach ($blockIds as $blockId) {
$content = self::renderBlock($blockId);
$string = str_replace("[[BLOCK_$blockId]]", $content, $string);
}
return $string;
}`
`public static function renderBlock(string $blockId, array $options = []) {
$block = self::find($blockId);
if ($block == null) {
return '';
}
...
}`