label('Überschrift')->default('Der Grundriss')->maxLength(120) ->helperText('Bild und Räume pflegen Sie unter Webseite › Grundriss.'), Textarea::make('text')->label('Text')->rows(2)->maxLength(300) ->default('Tippen Sie auf einen Raum, um Fotos und Ausstattung zu sehen.'), ]; } public function data(Theme $theme, array $data): array { $plan = $theme->property()?->floorPlan()->with('photo')->first(); $rooms = $plan?->photo ? $plan->visibleRooms() : collect(); $photos = Photo::query()->published()->with('media') ->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['photo_ids'] ?? [])->unique()->all()) ->get()->keyBy('id'); $amenities = Amenity::query() ->whereIn('id', $rooms->flatMap(fn (array $room): array => $room['amenity_ids'] ?? [])->unique()->all()) ->pluck('name', 'id'); return [ 'heading' => $data['heading'] ?? 'Der Grundriss', 'text' => $data['text'] ?? null, 'photo' => $plan?->photo, 'rooms' => $rooms->map(fn (array $room, int $index): array => [ 'key' => 'raum-'.Str::slug($room['name']).'-'.($index + 1), 'name' => $room['name'], 'description' => $room['description'] ?? null, 'hint' => $room['hint'] ?? null, 'points' => collect(FloorPlan::points($room['points']))->map(fn (array $point): string => $point[0].','.$point[1])->implode(' '), 'photos' => collect($room['photo_ids'] ?? [])->map(fn ($id) => $photos->get((int) $id))->filter()->values(), 'amenities' => collect($room['amenity_ids'] ?? [])->map(fn ($id) => $amenities->get((int) $id))->filter()->values(), ]), ]; } }