<div class="table-responsive">
    <table class="table table-sm table-hover table-striped table-bordered mb-0">
        <thead class="fw-bold text-secondary bg-light">
            <tr>
                <th>Created At</th>
                <th>User ID</th>
                <th>Lab</th>
                <th>Tests</th>
            </tr>
        </thead>
        <tbody>
            @foreach ($records as $record)
                <?php 
                    $detailJson = (array) $record->detailJson(true);
                    if(isset($detailJson['lab']) && isset($detailJson['lab']['hrs_of_operation'])){
                        unset($detailJson['lab']['hrs_of_operation']);
                    }  
                    $lab = (array) @$detailJson['lab'];
                    $tests = (array) @$detailJson['tests'];                     
                ?>
                <tr>
                    <td>{{ friendly_date($record->created_at ?? $record->updated_at) }}</td>
                    <td>
                        @if($record->user())
                            <?php $user = $record->user(); ?>
                            <a href="{{ route('admin.users.view.dashboard', $user) }}">{{ $user->displayName() }}</a>
                            <div class="d-flex" style="gap:16px;">
                                <span>Sex: <b>{{ $user->getDetailJsonValue('sex') }}</b></span>
                                <span>E: <b>{{ $user->getEmail() }}</b></span>
                                <span>DOB: <b>{{ friendly_date($user->getDetailJsonValue('dob')) }}</b></span>
                                <span>P: <b>{{ $user->getDetailJsonValue('phoneNumber') }}</b></span>
                            </div>
                        @else
                            ---
                        @endif
                    </td>
                    <td><?= labAddress($lab) ?></td>
                    <td>
                        @foreach($tests as $key =>$amount)
                            <span><b>{{ getTestLabelByKey($key) }}</b> - ${{ $amount }}</span>
                        @endforeach
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>
</div>
