@php
$initialAlternates = old('alternates');
if (!$initialAlternates) {
$initialAlternates = (isset($component) ? $component->alternates : collect())->map(fn($a) => [
'id' => $a->id,
'part_number' => $a->part_number,
'description' => $a->description,
'manufacturer_id' => $a->manufacturer_id,
'supplier_id' => $a->supplier_id,
'supplier_part_number' => $a->supplier_part_number,
'notes' => $a->notes,
])->toArray();
}
@endphp
Alternate Parts
Each alternate can have its own manufacturer and supplier, independent of the primary part above.
@foreach($initialAlternates as $i => $alt)
@include('procurement::components.partials.alternate_row', ['index' => $i, 'alt' => $alt, 'manufacturers' => $manufacturers, 'suppliers' => $suppliers])
@endforeach
@include('procurement::components.partials.alternate_row', ['index' => '__INDEX__', 'alt' => [], 'manufacturers' => $manufacturers, 'suppliers' => $suppliers])
@push('scripts')
@endpush