@php $qcGenCatalog = $qcGeneralCheckCatalog ?? ['domains' => [], 'activities' => [], 'checks' => []]; /** @var \Illuminate\Support\Collection $qcChecksById */ $qcChecksById = $qcChecksById ?? collect(); $domainsCol = collect($qcGenCatalog['domains'] ?? []); $activitiesCol = collect($qcGenCatalog['activities'] ?? []); $checksCol = collect($qcGenCatalog['checks'] ?? []); $rowsOld = report_wizard_rows('part_c.general_check.rows', [[ 'report_qc_domain_id' => '', 'report_qc_check_definition_id' => '', 'readings_yn' => '', 'found_places' => '', 'remarks' => '', ]], $reportPayload ?? null); // Plain arrays so scripts always receive id / report_qc_domain_id / report_qc_activity_id (no Model JSON quirks). $reportC1CatalogForJs = [ 'domains' => $domainsCol->map(fn ($d) => [ 'id' => (int) $d->id, 'name' => (string) $d->name, ])->values()->all(), 'activities' => $activitiesCol->map(fn ($a) => [ 'id' => (int) $a->id, 'report_qc_domain_id' => (int) $a->report_qc_domain_id, 'name' => (string) $a->name, ])->values()->all(), 'checks' => $checksCol->map(fn ($c) => [ 'id' => (int) $c->id, 'report_qc_activity_id' => (int) $c->report_qc_activity_id, 'name' => (string) $c->name, 'standard' => $c->standard !== null ? (string) $c->standard : null, 'found_places_hint' => $c->found_places_hint !== null ? (string) $c->found_places_hint : null, ])->values()->all(), ]; @endphp {{-- Part C §1 — General Check: QB-style rows; Domain → Activity → Name of test; + ADD ROW --}} @if ($domainsCol->isEmpty())

General Check catalog has no rows in the database. Run php artisan db:seed --class=ReportQualityCatalogSeeder (or full db:seed), then reload.

@endif
@foreach ($rowsOld as $rIdx => $row) @php $did = old('report.part_c.general_check.rows.'.$rIdx.'.report_qc_domain_id', $row['report_qc_domain_id'] ?? ''); $cid = old('report.part_c.general_check.rows.'.$rIdx.'.report_qc_check_definition_id', $row['report_qc_check_definition_id'] ?? ''); /** @var \App\Models\ReportQcCheckDefinition|null $checkDef */ $checkDef = $cid !== '' && $cid !== null && $qcChecksById->has($cid) ? $qcChecksById->get($cid) : null; $activityIdForRow = ($checkDef && $checkDef->activity) ? (string) $checkDef->report_qc_activity_id : ''; $activitiesForDomain = ($did !== '' && $did !== null) ? $activitiesCol->filter(fn ($act) => (int) $act->report_qc_domain_id === (int) $did)->values() : collect(); if ($activitiesForDomain->count() === 1 && $activityIdForRow === '') { $activityIdForRow = (string) $activitiesForDomain->first()->id; } $checksForActivity = $activityIdForRow !== '' ? $checksCol->filter(fn ($chk) => (int) $chk->report_qc_activity_id === (int) $activityIdForRow)->values() : collect(); $readings = old('report.part_c.general_check.rows.'.$rIdx.'.readings_yn', $row['readings_yn'] ?? ''); $foundPlaces = old('report.part_c.general_check.rows.'.$rIdx.'.found_places', $row['found_places'] ?? ''); $remarks = old('report.part_c.general_check.rows.'.$rIdx.'.remarks', $row['remarks'] ?? ''); $dotBase = 'report.part_c.general_check.rows.'.$rIdx.'.'; @endphp @endforeach
Domain Activity / Material Name of the Test Readings Actual at Site (YES/NO) Found in # of Places Standard Remarks (+ / -)
@error($dotBase.'report_qc_domain_id') {{ $message }} @enderror @error($dotBase.'report_qc_check_definition_id') {{ $message }} @enderror @error($dotBase.'readings_yn') {{ $message }} @enderror {{ $checkDef && $checkDef->found_places_hint ? $checkDef->found_places_hint : '' }} @error($dotBase.'found_places') {{ $message }} @enderror {{ $checkDef ? ($checkDef->standard ?: '—') : '—' }} @error($dotBase.'remarks') {{ $message }} @enderror
@push('scripts') @endpush