Laravel 5 Laravel:相乘列的和

Laravel 5 Laravel:相乘列的和,laravel-5,Laravel 5,在我的sql数据库中有一个名为details的表,我使用两个表中的两行,例如特定表中的price和req表中的quantity $particulars =DB::table('particulars as A') ->leftjoin('reqs as B', function ($join) { $join->on('A.particular_id', '=', 'B.particular_id'); })

在我的sql数据库中有一个名为
details
的表,我使用两个表中的两行,例如特定表中的price和req表中的quantity

  $particulars =DB::table('particulars as A')
        ->leftjoin('reqs as B', function ($join) {
            $join->on('A.particular_id', '=', 'B.particular_id');
        })
        ->whereBetween('B.date_issued', [$start_date, $end_date]) >select('A.item_name','A.unit','A.price','B.quantity_issued',DB::raw('sum(A.price*B.quantity_issued) as total_cost'))
        ->groupBy('A.particular_id')
        ->get();
我想在价格和数量相乘后得到总和,即我在相乘后得到的总成本的总和。 这是我的看法

    <table cellspacing="0">
    <thead style="background-color: grey">
    <tr style="">
        <th >Quantity</th>
        <th>price</th>
        <th>Total Cost</th>
    </tr>
    </thead>
    <tbody> @foreach($particulars as $particular)
        <tr>
           <td>{{$particular->quantity_issued}}</td>             
            <td>&nbsp;{{$particular->price}}</td>
            <td>&nbsp;{{$particular->total_cost}}</td>
        </tr>
    @endforeach
    </tbody>
    <tfoot>
    <tr>
        <td colspan="5" style="text-align: center">Total</td>
        <td class="total"></td>
    </tr>
    </tfoot>
</table>

量
价格
总成本
@foreach($具体细节)
{{$special->发行数量}
{{$special->price}
{{$special->total_cost}
@endforeach
全部的

您的输入有误

->whereBetween('B.date_issued', [$start_date, $end_date])>select

应为->选择

我是指新生成列的总和(总计)