Ejemplo n.º 1
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;
 }