В Laravel, если я хочу получить общую стоимость всех товаров в корзине, что мне добавить в свой код? Это cart.blade. php файл:
@extends('layouts.app')
@section('content')
<main class="container">
<section class="row justify-content-center">
<h1 class="text-center mb-5">Products on your cart:</h1>
</section>
<section class="row justify-content-center">
@foreach(Auth::user()->computers()->get() as $computer)
<div class="col-12 col-md-4">
<h2 class="text-center">{{$computer->name}}</h2>
<img class="card-img-top" src="{{Storage::url($computer->img)}}" alt="">
<form action="{{route('computers.removepc',['id'=>$computer->id])}}" method="POST">
@csrf
<center><button class="btn btn-danger mb-5" type="submit">Remove</button></center>
<p class="text-center">Price: {{$computer->price}}</p> //This is the single price of each product
</div>
@endforeach
</section>
<section class="row justify-content-center">
<h1>Here I want the total price</h1> //Here is , for example, where i want the total price of all computers in the cart
</section>
</main>
@endsection
Спасибо за помощь!