label('Kleine Überschrift')->maxLength(100), TextInput::make('heading')->label('Überschrift')->default('Unsere Tipps für Kühlungsborn')->maxLength(160), Textarea::make('text')->label('Text')->rows(2)->maxLength(400), TextInput::make('signature') ->label('Unterschrift') ->helperText('Steht unter jedem Tipp, z. B. „Brigitte“. Leer lassen für keine.') ->maxLength(60), Repeater::make('tips') ->label('Tipps') ->addActionLabel('Tipp hinzufügen') ->helperText('Vier oder sechs Karten wirken am ruhigsten.') ->defaultItems(0) ->maxItems(9) ->collapsible() ->itemLabel(fn (array $state): ?string => $state['title'] ?? null) ->columns(2) ->schema([ TextInput::make('title')->label('Ziel')->placeholder('Gespensterwald')->required()->maxLength(80), static::photoSelect('photo_id', 'Foto'), Textarea::make('tip') ->label('Ihr Tipp (Rückseite)') ->placeholder('Am schönsten am späten Nachmittag, wenn die Sonne durch die Buchen fällt …') ->rows(3) ->required() ->maxLength(400) ->columnSpanFull(), TextInput::make('way')->label('Weg dorthin')->placeholder('25 Minuten mit dem Rad')->maxLength(80), TextInput::make('best_time')->label('Beste Zeit')->placeholder('Später Nachmittag')->maxLength(80), ]), ]; } public function data(Theme $theme, array $data): array { $tips = collect($data['tips'] ?? [])->filter(fn (mixed $tip): bool => is_array($tip) && filled($tip['title'] ?? null) && filled($tip['tip'] ?? null)); $photos = $this->photos($tips->pluck('photo_id')->filter()->values()->all())->keyBy('id'); return [ 'eyebrow' => $data['eyebrow'] ?? null, 'heading' => $data['heading'] ?? null, 'text' => $data['text'] ?? null, 'signature' => $data['signature'] ?? null, 'tips' => $tips->map(fn (array $tip): array => [ 'title' => (string) $tip['title'], 'photo' => $photos->get((int) ($tip['photo_id'] ?? 0)), 'tip' => (string) $tip['tip'], 'way' => filled($tip['way'] ?? null) ? (string) $tip['way'] : null, 'bestTime' => filled($tip['best_time'] ?? null) ? (string) $tip['best_time'] : null, ])->values()->all(), ]; } }