function copy($name, $desc, $url) { $page = new Page(); $page->name = $name; $page->description = $desc; $page->url = $url; $page->template_id = $this->template_id; $page->save(); foreach ($this->posts()->get() as $oldPost) { $post = new Post(); $post->page_id = $page->id; $post->section_id = $oldPost->section_id; $post->name = $oldPost->name; $post->save(); foreach ($oldPost->contents()->get() as $oldContent) { $content = new Content(); $content->value = $oldContent->value; $content->post_id = $post->id; $content->item_id = $oldContent->item_id; $content->save(); } foreach ($oldPost->attachments()->get() as $oldAttachment) { $attachment = new Attachment(); $attachment->value = $oldAttachment->value; $attachment->name = $oldAttachment->name; $attachment->post_id = $post->id; $attachment->item_type_id = $oldAttachment->item_type_id; $attachment->save(); } } return $page; }
function post() { $page = new Page(); $page->name = Input::get('name'); $page->description = Input::get('description'); $page->url = Input::get('url'); $page->template_id = Input::get('template_id'); $page->language_id = Input::get('language_id'); $page->save(); return Redirect::to("/admin/manage-pages/" . $page->id . "/content"); }