1 | <?php |
||
10 | class MiniCms |
||
11 | { |
||
12 | public $pageBlocks = null; |
||
13 | |||
14 | public function createPage(array $pageData = []): Page |
||
18 | |||
19 | public function getPageBySlug(string $slug): Page |
||
23 | |||
24 | public function renderAdmin() |
||
51 | |||
52 | public function getBlockOutput(String $type, String $label, string $pageSlug = null) |
||
53 | { |
||
54 | $request = request(); |
||
55 | $page = $pageSlug ? Page::findBySlug($pageSlug) : $request->route('page'); |
||
56 | if (!$page && $request->is('/')) { |
||
57 | $page = Page::findBySlug(('home')); |
||
58 | } |
||
59 | |||
60 | if (!$this->pageBlocks) { |
||
61 | $this->pageBlocks = $page->pageBlocks(); |
||
62 | } |
||
63 | |||
64 | if ($this->pageBlocks->count() === 0) { |
||
65 | return ''; |
||
66 | } |
||
67 | $block = $this->pageBlocks->where('block.label', $label)->where('block.type', $type)->first(); |
||
68 | return $block ? $block->render() : ''; |
||
69 | } |
||
70 | |||
71 | public function renderBlock(String $type, String $label, string $pageSlug = null) |
||
75 | } |
||
76 |