label('Überschrift')->default('Das sagen unsere Gäste')->maxLength(120), TextInput::make('limit')->label('Anzahl')->integer()->minValue(1)->default(6), ]; } public function data(Theme $theme, array $data): array { $published = Review::query()->published() ->when($theme->property(), fn ($query, $property) => $query->whereBelongsTo($property)); return [ 'heading' => $data['heading'] ?? null, 'reviews' => (clone $published)->limit((int) ($data['limit'] ?? 6))->get(), 'count' => (clone $published)->count(), 'average' => round((float) (clone $published)->avg('rating'), 1), 'categories' => collect(Review::CATEGORIES) ->map(fn (string $label, string $field): array => ['label' => $label, 'average' => round((float) (clone $published)->avg($field), 1)]) ->filter(fn (array $category): bool => $category['average'] > 0) ->values(), ]; } }