Alreay i sum the column price groupby inventory_id .Additionally i need to calculate total price.
$record = ProductDetails::with('inventoryName')->whereDate('created_at', '=', date($date))
->select('inventory_id',DB::raw('sum(price) as item_price'),DB::raw('sum(quantity) as quantity'))->groupBy('inventory_id')->get();
My output is :
[
{
inventory_id: 9,
item_price: 30,
quantity: 30,
inventory_name: [
{
id: 9,
name: "sugar"
}
]
},
{
inventory_id: 10,
item_price: 70,
quantity: 70,
inventory_name: [
{
id: 10,
name: "oil"
}
]
}
]
Now i need to calculate total price.How to do this.