<table>
    <thead>
        <tr>
            <th>Team Member Name</th>
            <th>Check In Time</th>
            <th>Location</th>
            <th>Check Out Time</th>
            <th>Location</th>
            <th>Time Difference</th>
        </tr>
    </thead>
    <tbody>
        @foreach($query as $val)
        <tr>
            <td>{{ $val->customer->CustomerName ?? '' }}</td>
            <td>{{ $val->check_in_time ? $val->check_in_time->format('d-m-Y H:i:s') : '' }}</td>
            <td>{{ $val->check_out_time ? $val->check_out_time->format('d-m-Y H:i:s') : '' }}</td>
            <td>https://www.google.com/maps?q={{$val->checkin_lat}},{{$val->checkin_lng }}</td>
            <td>
                @if($val->checkout_lat && $val->checkout_lng)
                    https://www.google.com/maps?q={{$val->checkout_lat}},{{$val->checkout_lng }}
                @endif
            </td>
            <td>
                <?php 
                if ($val->check_in_time && $val->check_out_time) {
                    $checkIn = $val->check_in_time;
                    $checkOut = $val->check_out_time;
                    $difference = $checkIn->diff($checkOut); // Calculate time difference
                    echo $difference->format('%h hours %i minutes'); // Display time difference in hours and minutes
                }
                ?>
            </td>
        </tr>
        @endforeach
    </tbody>
</table>
