/** * Synchronize template blocks. * * @param Template $template * @param [type] $xmlBlock * * @return void */ protected static function syncTemplateBlock(Template $template, $xmlBlock) { $blockIdentifier = (string) $xmlBlock->attributes->identifier; $blockTitle = (string) $xmlBlock->attributes->title; $blockIdentifier = str_slug($blockIdentifier); $block = $template->blocks()->whereIdentifier($blockIdentifier)->first(); if ($block) { $block->title = $blockTitle; $block->save(); } else { $template->blocks()->create(['identifier' => $blockIdentifier, 'title' => $blockTitle]); } }