/** Edit Page */ public function editPage($pageId = 0, $contentId = false) { $page = Page::find($pageId); if (!$page) { return Redirect::route('cmsEdit'); } if (!ctype_digit(strval($pageId))) { throw new Exception('Invalid page-ID! Must be an integer value'); } if ($pageId <= 0) { throw new Exception($pageId . ' is not a valid page-ID'); } if (is_numeric($contentId) and $contentId > 0) { $page = Page::join("content", "content.page_id", "=", "pages.id")->where(function ($query) use($contentId) { $query->where('content.content_id', '=', $contentId); })->first(); if (empty($page->id)) { throw new Exception('Invalid Content-ID'); } } else { $page = Page::find($pageId); if (empty($page->id)) { throw new Exception('Invalid page-ID'); } $page->title = $page->content->title; $page->body = $page->content->body; $page->content_id = $page->content->content_id; } View::share("title", Lang::get('cms::m.edit-page') . " - " . $page->content->title); return View::make('cms::edit.pages.edit-page', array("rules" => $this->rules['page'], "page" => $page, "history" => Page::history($pageId), "current_content_id" => $page->content_id)); }