Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$ventasConTotales = Venta::join("productos_vendidos", "productos_vendidos.id_venta", "=", "ventas.id")
->select("ventas.*", DB::raw("sum(productos_vendidos.cantidad * productos_vendidos.precio) as total"))
->groupBy("ventas.id", "ventas.created_at", "ventas.updated_at")
->get();
return view("ventas.ventas_index", ["ventas" => $ventasConTotales,]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.