i want to update previous record of db table using some conditions there is $order is a last record of db
and $old_order[1] is 2nd last order it should update previous order data but it only delete order not update previous order here is code
if( $order->ot_customer_distance * 1000 < 200 )
$old_order = Order::where('customer_id' , $order->customer_id)->orderBy('id' , 'desc')->get();
$chk_ord = $old_order[1]->chk_ord_vst;
$old_order_id = $old_order[1]->id;
if($chk_ord >= 4){
$setorder = 2;
}
elseif($chk_ord == 3){
$setorder = 2;
}
elseif($chk_ord == 2){
$setorder = 1;
}
elseif($chk_ord <= 1){
$setorder = 0;
}
$succ = Order::where('id', $old_order_id)->update(['chk_ord_vst'=> $setorder]);
$this->deleteorder($order->id);
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire