To solve this issue, you can check if the current date being looped over in the thead section exists in the current client's work reports. If it does, display the work hours for that date, otherwise display a dash (-) symbol. Here's an updated version of the tbody section in the blade file:
<tbody>
@foreach($workreports->groupBy('clientname.client_name') as $cliname => $workreport)
<tr>
<td>{{ $loop->iteration }}</td>
<td>{{ $cliname ?? "-" }}</td>
@php $total = 0; @endphp
@foreach($workreports->unique('wk_date') as $workdate)
@php
$workhrs = $workreport->firstWhere('wk_date', $workdate->wk_date);
@endphp
<td>{{ $workhrs ? $workhrs->wk_hrs : "-" }}</td>
@php $total += $workhrs ? $workhrs->wk_hrs : 0; @endphp
@endforeach
<td>{{ $total }}</td>
</tr>
@endforeach
</tbody>
In this updated version, we loop over the unique dates in the thead section instead of the work reports. Then, in the tbody section, we loop over the unique dates again and check if the current client's work reports contain a record for that date using the firstWhere method. If a record exists, we display the work hours for that date, otherwise we display a dash (-) symbol.