I am trying to find the id of a sale in order to update the detail table Sale. This when that sale has already been charged.
I have a function in this way, in the sale table it looks for and updates the id of the sale but in its detail it does not generate it. How can I find out the id of the sale to update the detail table?
public function cobrar(Request $request, $id)
{
$buscarPago = VentaUtp::findOrFail($id);
$buscarPago->cantidadPagada="300";
$buscarPago->update();
$actualizarDetalle = DB::table('alumnopagosdet')
->select('idAlumnoCxC')
->where('idAlumnoCxC', '=', $id)
->get();
$mytime = Carbon::now('America/Mexico_City');
$venta->fecha_hora=$mytime->toDateTimeString();
$actualizarPago = DetalleVentaUtp::findOrFail($detalle);
$actualizarPago->fecha= $venta;
$actualizarPago->caja=$request->get('caja');
$actualizarPago->reciboCaja=$request->get('reciboCaja');
$actualizarPago->anio=$request->get('anio');
$actualizarPago->mes=$request->get('mes');
$actualizarPago->cantidad=$buscarPago->cantidadPagada;
$actualizarPago->update();
return Redirect::to('utp/venta');
}