php - Displays 3 data from 1 table into 1 row of data in laravel

please help, I want to display the date data ($absen->tanggal) in the table column according to the date header. But I am confused, the data does appear but it repeats as many as the number of data in the database table (3 data), how do you make the 3 data into 1 data appear in 1 table row.
this is my table in my blade:
<tr>
<th>No</th>
<th>Id_karyawan</th>
<th>Nama</th>
<th>Cabang</th>
<th>Jabatan</th>
<th>Divisi</th>
@for ($i = 0; $i <= $diff->d; $i++)
<?php
$y=$i*1440;
$tanggals = date("d-m-Y", strtotime($y.' minutes', strtotime($tglawal)));
?>
<th style="width:600px;">{{$tanggals}}</th>
@endfor
<th>Keterangan</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $no = 0 ; ?>
@foreach($data as $dt)
<?php $no++ ; ?>
<tr>
<td> {{ $no }} </td>
<td> {{ $dt->id_karyawan }} </td>
<td> {{ $dt->nama }} </td>
<td> {{ $dt->nama_cabang }} </td>
<td> {{ $dt->jabatan }} </td>
<td> {{ $dt->divisi }} </td>
@foreach($absen->where('id_karyawan',$dt->id_karyawan) as $absen)
@for ($i = 0; $i <= $diff->d; $i++)
<?php
$y=$i*1440;
$tanggals = date("Y-m-d", strtotime($y.' minutes', strtotime($tglawal)));
?>
@if($absen->tanggal == $tanggals)
<td style="width:600px;">{{ $tanggals }}</td>
@else
<td style="width:600px;">0</td>
@endif
@endfor
@endforeach
<td> {{ $dt->keterangan }} </td>
<td><a href="" class="btn btn-primary btn-block btn-sm">Buka</a></td>
</tr>
@endforeach
</tbody>
and this my controller :
$tglawal = $request->mulai_tanggal;
$tglakhir = $request->sampai_tanggal;
$awal = date_create("$request->mulai_tanggal");
$akhir = date_create("$request->sampai_tanggal");
$diff = date_diff( $awal, $akhir );
if($request->cabang != "") {
$data = Karyawan::select("karyawan.*","jabatan.*","cabang.*")
->join('jabatan', 'jabatan.kode_jabatan', '=', 'karyawan.kode_jabatan')
->join('cabang', 'cabang.kode_cabang', '=', 'karyawan.kode_cabang')
->where('karyawan.kode_cabang',"$request->cabang")
->get();
$absen = Absen::all();
}else{
}
and this my view with my code now :
Pls Help Me ...
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: undefined array key
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.