这里我想添加我基于id_data kos
的数据,所以每当我添加数据时都会自动计算id_data_kos
。通过数据计算laravel
这里我的控制器:
$limit = 10;
$result = DB::table('residents')
->join("data_kos","data_kos.id","=","residents.id_data_kos")
->select("residents.*","data_kos.title as data_title")
->groupBy('id_data_kos')
->orderBy('residents.id', 'asc');
$data['posts'] = $result->paginate($limit);
,这我的观点:
@foreach($posts as $row)
<td>{{ $row->data_title }}</td>
<td>here i want to count</td>
@endforeach
这是我的表:
你的问题是不明确的,你要计算行数? – user3426711
是的,计算,例如当我输入新数据与id_data_kos 2 id_data_kos将导致2 –
好吧,你想要计数:对于每一行,具有相同的'id_data_kos'记录数?我对吗? – user3426711