Created
March 6, 2020 21:24
-
-
Save parzibyte/7b514439f42c479a7a13740dbfd2f239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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