Ich habe diesen Code hier:Wie erhalten Sie einen Zwischen- und Gesamtpreis? Laravel foreach Schleife
@foreach($products as $p)
<tr>
<td class="col-md-6">
<div class="media">
<a class="thumbnail pull-left" href="#"> <img class="media-object" src="{{URL::to($p['image'])}}" style="width: 72px; height: 72px;"> </a>
<div class="media-body">
<span style="padding-left: 20px">Pavadinimas: </span><span class="text-warning"><strong>{{$p['title']}}</strong></span>
</div>
</div>
</td>
<td class="col-md-1" style="text-align: center">
<input type="number" class="form-control" id="quantity" value="{{$p['quantity']}}">
</td>
<td class="col-md-1 text-center">
<strong>{{$p['price']}} EUR</strong>
</td>
<td class="col-md-1 text-center">
<strong>{{$p['price']*$p['quantity']}} EUR</strong>
</td>
<td class="col-md-1">
<button type="button" class="btn btn-danger">
<span class="glyphicon glyphicon-remove"></span> Pašalinti
</button>
</td>
</tr>
@endforeach
die $products
ist in foreach-Schleife, und ich weiß nicht, wie die alle Preis zu bekommen, wenn es zwei sind, drei oder mehr Produkte, weil ich don weiß nicht wie man eine Variable außerhalb der foreach Schleife setzt. Denn wenn ich diesen Code in foreach-Schleife von Add-Recht nicht jetzt in foreach-Schleife hinzugefügt:
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><h5>Subtotal</h5></td>
<td class="text-right"><h5><strong> EUR</strong></h5></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><h5>Another taxes</h5></td>
<td class="text-right"><h5><strong>1.44 EUR</strong></h5></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><h3>Total</h3></td>
<td class="text-right"><h3><strong> EUR</strong></h3></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td>
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-shopping-cart"></span> Žiūrėti kitas prekes
</button>
</td>
<td>
<button type="button" class="btn btn-success">Užsakyti
<span class="glyphicon glyphicon-play"></span>
</button>
</td>
</tr>
Dieser Code wird nur dupliziert. Also jeder Vorschlag, wie man den Gesamtpreis aller Produkte im Warenkorb erhält, ohne dieses Stück Code in foreach loop hinzuzufügen?