function post()
 {
     $pageId = Request::route('id1');
     $sectionId = Request::route('id2');
     $section = Section::find($sectionId);
     $inputs = $this->inputs();
     $post = new Post();
     $post->page_id = $pageId;
     $post->section_id = $sectionId;
     $post->name = $section->name;
     $post->description = $section->description;
     $post->save();
     foreach ($inputs as $input) {
         $item = Item::find($input->id);
         $content = null;
         if (isset($content) === false) {
             $content = new Content();
             $content->item_id = $item->id;
             $content->post_id = $post->id;
             $input->insert($content, Input::get("{$item->id}"));
         }
         //            else {
         //                $input->update($content, Input::get("$item->id"));
         //            }
         $content->save();
     }
     return Redirect::to("/admin/manage-pages/{$pageId}/content");
 }
Esempio n. 2
0
 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;
 }