dimanche 7 juillet 2019

How to calculate sum of order in laravel?

If i have order_id of 15 with subtotal of 10$, $20 that belong to seller_id of 1, another order_id of 15 with subtotal of 15$ that belong to seller_id of 2. How can i get a total for each seller.

Right now i'm getting the sum for the whole order of 15 even though it has different seller_id. This is how the table looks like !https://imgur.com/1nuF7XH

This is the logic of how i calculate total right now

$product = product::find($productId);
           OrderProduct::create([
            'quantity' => $item['quantity'],
            'Subtotal' =>$item['pro_price'] * $item['quantity'],
            'total' => $total += $item['pro_price'] *   $item['quantity'],

this is blade

@foreach ($order->orderItems as $item)
@if($item->product->user_id == $userID)
    <td></td>
    <td></td>
@endif
@endforeach

Any help would be appreciated



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire