php - Laravel4 duplicate / copy table row -


i'm sure there has quicker way following. wasn't able find how save laravel modal object new row without overwriting existing item. essentially, simpler of existing code:

$olditem = item::find(1); $newitem = new item; $newitem->key = $olditem ->key; $newitem->name = $olditem ->name; $newitem->path = $olditem ->path; $newitem->save(); 

instead, copying id of row:

$olditem = item::find(1); $newitem = $olditem; unset($newitem->id); $newitem->save(); 

you can try

$newitem = item::find(1)->replicate()->save(); 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -