/** * Register the listeners for the subscriber. * * @param Events $events */ public function subscribe(Events $events) { $events->listen('content.dispatch.renderSection', function (&$blocks, $section, $page, $isContentMode, $isModePublic) { if (!$isContentMode || !$isModePublic) { return; } $block = Block::whereController('Boyhagemann\\Text\\Controller\\TextController@textarea')->first(); $fb = App::make('formbuilder'); $fb->route('admin.content.config.store'); $fb->hidden('page_id')->value($page->id); $fb->hidden('section_id')->value($section->id); $fb->hidden('block_id')->value($block->id); $fb->wysiwyg('text'); $textForm = $fb->build(); $blocks[] = View::make('text::add-text-from-section', array(), compact('textForm', 'section')); }); }
/** * @param Page $page */ public function onCreateResourcePage(Page $page) { // Check if there already is content attached to this page. // If so, then we don't have to add new content. if (Content::wherePageId($page->id)->first()) { return; } $block = Block::whereController($page->controller)->first(); $section = Section::whereName('content')->first(); $content = new Content(); $content->page()->associate($page); $content->section()->associate($section); if ($block) { $content->block()->associate($block); } else { $content->controller = $page->controller; } $content->save(); }