{{-- One form field from a LoanDataFields / ContactFields definition. Expects: $model, $col, $def ([label, type, source?]). --}} @php [$label, $type] = $def; $raw = $model->getAttribute($col); if ($raw instanceof \DateTimeInterface) { $raw = $raw->format('Y-m-d'); } if ($type === 'dmy' && $raw) { $raw = \App\Services\Crm\SavedViewSchema::parseDate($raw) ?? $raw; } $required = $col === 'contact_name'; @endphp @switch($type) @case('select') @case('carinfo') @php($options = \App\Services\Crm\LoanDataFields::options($def)) @php($current = (string) old($col, $raw)) @if ($current !== '' && ! in_array($current, $options, true)) @php($options[] = $current) @endif @break @case('date') @case('dmy') @break @case('number') @break @case('textarea') @break @default @endswitch