title: Laravel total of products from Pivot table
body: <pre><code> @foreach($order-&gt;products as $product)
  
                      &lt;tr&gt;
  
                          &lt;td&gt; {{ $product-&gt;id }}&lt;/td&gt;
                          &lt;td&gt; {{ $product-&gt;name }}&lt;/td&gt;
                          &lt;td&gt; {{ $product-&gt;getRelationValue('pivot')-&gt;qty }} &lt;/td&gt;
                          &lt;td&gt; {{ $product-&gt;getRelationValue('pivot')-&gt;price }} &lt;/td&gt;
                          &lt;td&gt; {{ $total = $product-&gt;getRelationValue('pivot')-&gt;price * $product-&gt;getRelationValue('pivot')-&gt;qty }} &lt;/td&gt;
                      &lt;/tr&gt;
  
                  @endforeach
  Grand Total:{{$total}}
  </code></pre>
  
  <p>I would like to show the total value. Can someone help me out?
  And also the random access to $product->id in format 1,2,3....</p>