@php /** @var \App\Models\TallySheet $tallySheet */ $currentType = old('operation_type', $tallySheet->operation_type ?? 'discharging'); if (!in_array($currentType, ['discharging', 'loading'])) { $currentType = 'discharging'; } $rawSheets = old('sheets', $tallySheet->resolved_sheets ?? []); if (empty($rawSheets)) { $rawSheets = [ [ 'sheet_no' => old('sheet_no', $tallySheet->sheet_no ?: '1'), 'date' => old('commenced_date', $tallySheet->commenced_date ?: ($tallySheet->berthed_date ?: '')), 'tally_items' => old('tally_items', $tallySheet->tally_items ?? \App\Models\TallySheet::getDefaultTallyItems(10)), 'totals' => $tallySheet->totals ?? \App\Models\TallySheet::getDefaultTotals(), ] ]; } $titleVal = old('title', $tallySheet->title ?: \App\Models\TallySheet::getTitleForType($currentType)); @endphp @if(isset($errors) && $errors->any())