/** * @param $title * @param array $content (array with body, and any custom data) * @param int $parent_id */ public static function createPage($data = array(), $parent_id = 0) { $page = new Page(); $page->publish_start = date("Y-m-d H:i"); foreach ($data['page'] as $field => $value) { $page->{$field} = $value; } $page->crawled = 1; $page->save(); $pageId = $page->id; $content = new Content(); $content->page_id = $pageId; foreach ($data['content'] as $field => $value) { $content->{$field} = $value; } //$content->custom_content_right = $content['content_right']; $content->save(); }
public function savePage($pageId) { //Update Page $page = Page::find($pageId); //Alter menu only if menu_id is in Input if (Input::get('menu_id') > 0) { //Set parent_id to 0 if new menu_is not same as old if ($page->menu_id != Input::get('menu_id')) { $page->parent_id = 0; } $page->menu_id = Input::get('menu_id'); } $page->allow_dropdown = Input::get('allow_dropdown'); //$page->parent_id = $parent_id; $page->controller = Input::get('controller'); $page->template = Input::get('template'); $page->link = Helper::createLink(Input::get('link')); $page->order = Input::get('order'); $page->published = Input::get('published'); $page->publish_start = Input::get('publish_start'); $page->publish_end = Input::get('publish_end'); $page->slug = Helper::createPageSlug(Input::get('title'), $pageId); $page->save(); //Modify URL after save according to new info $page->url = Page::getUrl($page->id); $page->save(); //Create New Content Version $content = new Content(); $content->page_id = $page->id; $content->title = Input::get('title'); $content->body = Input::get('body'); $content->save(); return Redirect::route('editPage', array($pageId))->with('flash_notice', Lang::get('cms::m.saved')); }