Named travel windows for this destination — they are listed on the website destination page. Leave a row's name blank to drop it.
@php
// old() wins after a failed validation pass so nothing typed is lost; otherwise
// the saved rows, and always at least one empty row to type into.
$pickTimes = old('pick_times', isset($item)
? $item->pickTimes->map(fn ($pt) => [
'name' => $pt->name,
'start_date' => $pt->start_date?->format('Y-m-d'),
'end_date' => $pt->end_date?->format('Y-m-d'),
])->all()
: []);
// old() hands back whatever was posted, so it is not trusted to be well shaped.
$pickTimes = is_array($pickTimes) ? $pickTimes : [];
$pickTimes = $pickTimes ?: [['name' => '', 'start_date' => '', 'end_date' => '']];
// Rows removed before a failed submit leave gaps in the keys, so the next
// index has to come from the highest one used, not from the row count.
$nextPickTimeIndex = ((int) max(array_keys($pickTimes))) + 1;
@endphp