Skip to content

Instantly share code, notes, and snippets.

@giltotherescue
Created March 16, 2015 23:53
Show Gist options
  • Save giltotherescue/99ff2c3bda78ab8adea1 to your computer and use it in GitHub Desktop.
Save giltotherescue/99ff2c3bda78ab8adea1 to your computer and use it in GitHub Desktop.
$orig = Portfolio::findOrFail(Input::get('copy_portfolio'));
$portfolio = $orig->replicate();
$portfolio->title = Input::get('title');
$portfolio->push();
foreach ($orig->authors as $a)
{
$portfolio->authors()->attach($a);
}
foreach ($orig->audiences as $a)
{
$new = new Audience();
$new->fill_raw($a);
$portfolio->authors()->save($new);
}
foreach ($orig->editorComment as $a)
{
$new = new EditorComment();
$new->fill_raw($a);
$portfolio->editorComment()->save($new);
}
foreach ($orig->uploads as $a)
{
$new = new Upload();
$new->fill_raw($a);
$portfolio->uploads()->save($new);
}
$portfolio->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment