如何得到这个数据的乘法之和。
这是我的kvit表
id | hamkor_id | oper_type
1 | 10 | 20
这是操作表
id | kvit_id | product_id | store_id| amount | price
1 | 1 | 5 | 1 | 10 | 15
2 | 1 | 6 | 1 | 5 | 10
这里是关系
class Kvit extends Model
{
use HasFactory;
public function operation(){
return $this->hasMany(Operation::class);
}
public function hamkor(){
return $this->belongsTo(User::class, 'hamkor_id','id');
}
public function user(){
return $this->belongsTo(User::class);
}
public function store(){
return $this->belongsTo(Store::class);
}
}
这里是控制器
$user = Auth::id();
$datas = Kvit::with('user', 'hamkor', 'store', 'operation')->where('user_id', $user)->get();
return view('operations.index', compact('datas'));
这是我的看法
<table class="datatables-basic table" id="example">
<thead>
<tr>
<th>#</th>
<th></th>
<th>Date</th>
<th>Hamkor</th>
<th>Store</th>
<th>Summ</th>
<th>Amallar</th>
</tr>
</thead>
<tbody>
@foreach($datas as $idx => $data)
<tr>
<td>{{$idx+1}}</td>
<td></td>
<td>{{$data->date}}</td>
<td>{{$data->hamkor->name}}</td>
<td>{{$data->store->name}}</td>
<td>{{ **here i want to get result(200)** }}</td>
<td>
<a href="#" class="btn btn-icon btn-flat-primary">
<i class="fas fa-edit"></i>
Edit
</a>
<a href="#" class="btn btn-icon btn-flat-primary">
<i class="fas fa-view"></i>
View
</a>
<a href="#" class="btn btn-icon btn-flat-primary">
<i class="fas fa-trash"></i>
Delete
</a>
</td>
</tr>
@endforeach
</tbody>
我需要通过将每个产品的数量乘以价格来获得总金额。那就是收据的总金额 像这样(10 15 + 5 10) = 200 怎么可能呢?