Laravel,正在尝试使用数据库中的值进行计数
我需要一些关于Laravel的帮助,我正在尝试做一个列表,包含我数据库中的信息和计数,例如: 我如何计算同一位置在我的列表中出现的次数?记住:我的位置列表来自我的数据库,位置可以是变量。我不能算数。这是我的密码:Laravel,正在尝试使用数据库中的值进行计数,laravel,Laravel,我需要一些关于Laravel的帮助,我正在尝试做一个列表,包含我数据库中的信息和计数,例如: 我如何计算同一位置在我的列表中出现的次数?记住:我的位置列表来自我的数据库,位置可以是变量。我不能算数。这是我的密码: <table border=`1px` class="table-teste"> <tr> <td><h3> Place</h3></td> <td><h
<table border=`1px` class="table-teste">
<tr>
<td><h3> Place</h3></td>
<td><h3> Count</h3></td>
</tr>
@foreach ($setor_data as $setor)
<tr>
<td>{{$setor->setor}}</td>
</tr>
@endforeach
</table>
放置
计数
@foreach($setor_数据为$setor)
{{$setor->setor}
@endforeach
和我的控制器:
$setor_data = DB::table('atividades')
->where('local', $condominio)
->whereDate('date', '>=', $dtinicio)
->whereDate('date','<=',$dtok)
->orderBy("setor")
->select('setor')
->get();
$setor_data=DB::table('atividades')
->其中(‘本地’,$condominio)
->其中日期('date','>=',$dtinicio)
->whereDate('date','用户groupBy对查询列表中的每个项目进行计数,如下所示:
$setor_data = DB::table('atividades')
->where('local', $condominio)
->whereDate('date', '>=', $dtinicio)
->whereDate('date','<=',$dtok)
->orderBy("setor")
->select('setor', , DB::raw('count(*) as total'))
->get();
$setor_data=DB::table('atividades')
->其中(‘本地’,$condominio)
->其中日期('date','>=',$dtinicio)
->whereDate(‘date’,‘伙计,你是我的英雄它工作得很好,非常感谢你,你救了我的命,非常感谢,非常感谢纳泽姆,爱你
@foreach ($setor_data as $setor)
<tr>
<td>{{$setor->setor}}</td>
<td>{{$setor->total}}</td>
</tr>
@endforeach