I have the following code in a controller:
$total = DB::table('pedidos')->where('idUSUARIOS', $usuario)
->orWhere('ESTADO','P')
->pluck('TOTAL');
$precio=$request->get('precio');
DB::table('pedidos')
->where('idPEDIDOS',$idpedido)
->update(['TOTAL' => $total+$precio]);
What you are trying to do is what is in the TOTAL column to accumulate the price of another product, but I get an error in the following line:
->update(['TOTAL' => $total+$precio]);
The error it gives is:
Object of class Illuminate\Support\Collection could not be converted to int
Does anyone know the reason for this error?
Thank you very much in advance.