title: How to calculate sum of order in laravel?
body: <p>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.            </p>
  
  <p>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: 
  <a href="https://i.stack.imgur.com/0iltd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0iltd.png" alt="enter image description here"></a></p>
  
  <p>This is the logic of how I calculate total right now</p>
  
  <pre><code>$product = product::find($productId);
             OrderProduct::create([
              'quantity' =&gt; $item['quantity'],
              'Subtotal' =&gt;$item['pro_price'] * $item['quantity'],
              'total' =&gt; $total += $item['pro_price'] *   $item['quantity'],
  </code></pre>
  
  <p>this is the blade  </p>
  
  <pre><code>@foreach ($order-&gt;orderItems as $item)
  @if($item-&gt;product-&gt;user_id == $userID)
      &lt;td&gt;{{ $item-&gt;product-&gt;Subtotal }}&lt;/td&gt;
      &lt;td&gt;{{ $item-&gt;$totals }}&lt;/td&gt;
  @endif
  @endforeach
  </code></pre>
  
  <p>Any help would be appreciated.</p>