/** * Teardown block setup */ public static function tearDown() { $html = ob_get_clean(); end(self::$models); $slug = key(self::$models); $title = array_pop(self::$models); /** @var Block $block */ $block = Block::where('slug', $slug)->first(); if (!$block) { $block = new Block(['slug' => $slug, 'title' => $title, 'content' => trim($html)]); $block->save(); } if (Gate::allows('edit-html-blocks')) { return sprintf('<html-block slug="%s">%s</html-block>', $slug, trim($block->content)); } return trim($block->content); }
/** * Renders content of the given block * * @param string $slug Unique slug * @return string */ public static function render($slug) { /** @var Block $block */ $block = Block::where('slug', $slug)->first(); if (!$block) { return ''; } return $block->content; }