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
Post a Comment