Files
fewo-stommer/app/Filament/Resources/Reviews/Schemas/ReviewForm.php
T
LarsandClaude Opus 5.5 8bcda9a4bc Wohnungsumschalter im Verwaltungsmenue und wohnungsbezogene Listen
Oben im Seitenmenue waehlt man die Wohnung; Listen, neue Eintraege, Belegungsplan
und Preise & Angebote folgen ihr. Ein geoeffneter Eintrag einer anderen Wohnung
schaltet auf diese um. Galerie und Ersatz-Titelbild der Website zeigen nur Fotos
der Wohnung des Bausteins und Fotos ohne Wohnung.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 18:40:13 +01:00

69 lines
3.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace App\Filament\Resources\Reviews\Schemas;
use App\Enums\ReviewStatus;
use App\Models\Property;
use App\Models\Review;
use App\Support\CurrentProperty;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
class ReviewForm
{
public static function configure(Schema $schema): Schema
{
$stars = [1 => '★', 2 => '★★', 3 => '★★★', 4 => '★★★★', 5 => '★★★★★'];
return $schema
->columns(3)
->components([
Section::make('Bewertung')
->columnSpan(2)
->columns(2)
->schema([
TextInput::make('display_name')->label('Angezeigter Name')->required()->maxLength(80),
DatePicker::make('stayed_on')->label('Aufenthalt'),
Select::make('rating')->label('Gesamt')->options($stars)->required(),
...collect(Review::CATEGORIES)->map(fn (string $label, string $field) => Select::make($field)->label($label)->options($stars))->values()->all(),
TextInput::make('title')->label('Überschrift')->maxLength(120)->columnSpanFull(),
Textarea::make('body')->label('Text')->rows(5)->columnSpanFull(),
Textarea::make('private_feedback')
->label('Nur für die Gastgeber')
->rows(3)
->disabled(fn (?Review $record): bool => $record?->source === 'website')
->columnSpanFull(),
]),
Section::make('Freigabe')
->columnSpan(1)
->schema([
Select::make('status')->label('Status')->options(ReviewStatus::class)->default(ReviewStatus::Approved)->required(),
Toggle::make('publish_consent')
->label('Gast hat Veröffentlichung erlaubt')
->disabled(fn (?Review $record): bool => $record?->source === 'website'),
TextInput::make('source')
->label('Quelle')
->helperText('„website“ = über den Bewertungslink. Bei übernommenen Bewertungen das Portal eintragen.')
->default('manuell')
->disabled(fn (?Review $record): bool => $record?->source === 'website')
->required(),
Select::make('property_id')
->label('Wohnung')
->options(fn (): array => Property::query()->pluck('name', 'id')->all())
->default(fn (): ?int => app(CurrentProperty::class)->id())
->required(),
]),
Section::make('Öffentliche Antwort der Gastgeber')
->columnSpanFull()
->schema([
Textarea::make('response')->hiddenLabel()->rows(3)->placeholder('Optional – erscheint unter der Bewertung.'),
]),
]);
}
}