I am trying to duplicate data with a click of a button, in better terms, trying to reorder a previous order. This is my code
$order = Order::find($id);
$order_details = OrderDetail::where('order_id', $id)->get();
$reorder = $order->replicate();
$reorder_details = $order_details->replicate();
$reorder->save();
$reorder_details->save();
The $order
data replicates fine, however the $order_details
data doesnt, as I get this error Method Illuminate\Database\Eloquent\Collection::replicate does not exist.
Is there a way to duplicate without using replicate()
?
from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2PpEBjb
via IFTTT
Aucun commentaire:
Enregistrer un commentaire