/** * 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(); }
/** * @param Model $model */ protected function generatePages(Model $model) { // Determine the controller class name $controller = Str::studly($model->title) . 'Controller'; // Use a layout $layout = 'layouts.default'; $urlIndex = Str::slug($model->title); $aliasIndex = str_replace('.', '', $urlIndex); $urlShow = $urlIndex . '/{id}'; $aliasShow = $urlIndex . '.show'; $zone = 'content'; $method = 'get'; PageRepository::createWithContent($model->title, $urlIndex, $controller . '@index', $layout, $method, $aliasIndex); PageRepository::createWithContent($model->title, $urlShow, $controller . '@show', $layout, $method, $aliasShow); Block::create(array('title' => sprintf('List %s items', $model->title), 'controller' => $controller . '@index')); Block::create(array('title' => sprintf('Show %s', $model->title), 'controller' => $controller . '@show')); }