【发布时间】:2019-04-08 15:43:27
【问题描述】:
我有一个 HTML 表,我想在其中显示从数据库表中检索到的数据。
我过去用 php 成功地做到了这一点,但使用 Laravel,表格中没有显示任何内容:下面是在表格中显示数据的代码
<tbody>
@php
$total_sales = 0;
$comm_total = 0;
@endphp
@foreach ($comm as $data){
$comm_total += $data->sales_comm;
$total_sales += $data->sales_total;
<tr>
<td>{{$data->sales_date}}</td>
<td>{{$data->sales_total}}</td>
<td>{{$data->sales_comm}}</td>
</tr>
@endforeach
我希望检索数据库表中具有登录用户 ID 和所选月份和年份的每一行并将其显示在刀片表中。
这是控制器代码
$comm = \DB::table('bakerysales')->where('customer_id', Auth()->id()
->whereMonth('sales_date', $request->input('mn'))
->whereYear('sales_date', $request->input('yr'))
->get();
return view('showCommission', compact('comm'));
【问题讨论】:
-
使用
dd()导出$comm的值作为起点。