@extends('layouts.dashboard') @section('title', 'Import customers — map columns') @php // Best-effort guess so the common case needs no clicking: match a target // field's own key or label against the file's header text. $guessColumn = function (string $field, string $label) use ($headers) { foreach ($headers as $index => $header) { $normalised = strtolower(preg_replace('/[^a-z0-9]+/i', '', $header)); $fieldNormalised = strtolower(preg_replace('/[^a-z0-9]+/i', '', $field)); $labelNormalised = strtolower(preg_replace('/[^a-z0-9]+/i', '', explode(' (', $label)[0])); if ($normalised === $fieldNormalised || $normalised === $labelNormalised) { return $index; } } return null; }; @endphp @section('content')
{{ $rowCount }} row(s) found. Match each field below to a column in the file — leave a field unmatched to skip it.
@if (count($preview))| {{ $header }} | @endforeach
|---|
| {{ $row[$index] ?? '' }} | @endforeach