コード例 #1
0
 /**
  * @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();
 }
コード例 #2
0
 /**
  * @param Page $page
  */
 public function onCreateWithContent(Page $page)
 {
     // If the page doesn't have a controller, then we can do nothing
     if (!$page->controller || !$page->layout) {
         return;
     }
     // 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;
     }
     // Get the main content section
     $section = Section::whereName('content')->first();
     // Create the new content
     $content = new Content();
     $content->page()->associate($page);
     $content->section()->associate($section);
     $content->controller = $page->controller;
     $content->save();
 }
コード例 #3
0
ファイル: Page.php プロジェクト: boyhagemann/framework
 /**
  * @param        $title
  * @param        $route
  * @param        $controller
  * @param string $method
  * @param string $layout
  * @param string $section
  * @param array  $params
  * @param array  $match
  *
  * @return \Boyhagemann\Pages\Model\Page
  */
 public static function createWithContent($title, $route, $controller, $method = 'get', $layout = 'layouts.default', $section = 'content', $params = null, $match = null)
 {
     $layout = Layout::whereName($layout)->first();
     $section = Section::whereName($section)->first();
     $page = new Page();
     $page->title = $title;
     $page->route = $route;
     $page->layout()->associate($layout);
     $page->method = $method;
     $page->save();
     $content = new Content();
     $content->page()->associate($page);
     $content->section()->associate($section);
     $content->controller = $controller;
     $content->params = (array) $params;
     $content->match = (array) $match;
     $content->save();
     return $page;
 }