66 lines
2.9 KiB
PHP
66 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Guests\Schemas;
|
|
|
|
use App\Models\Guest;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TagsInput;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Infolists\Components\TextEntry;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
|
|
class GuestForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->columns(3)
|
|
->components([
|
|
Section::make('Kontakt')
|
|
->columnSpan(2)
|
|
->columns(2)
|
|
->schema(static::contactFields()),
|
|
Section::make('Verwaltung')
|
|
->columnSpan(1)
|
|
->schema([
|
|
...static::personalFields(),
|
|
TextEntry::make('marketing_consent_at')
|
|
->label('Einwilligung Angebote per E-Mail')
|
|
->state(fn (?Guest $record): string => $record?->marketing_consent_at ? 'bestätigt am '.$record->marketing_consent_at->format('d.m.Y') : 'keine'),
|
|
TextEntry::make('anonymized_at')
|
|
->label('Anonymisiert')
|
|
->dateTime('d.m.Y')
|
|
->visible(fn (?Guest $record): bool => $record?->anonymized_at !== null),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
/** @return array<TextInput|Select> */
|
|
public static function contactFields(): array
|
|
{
|
|
return [
|
|
TextInput::make('first_name')->label('Vorname')->required()->maxLength(255),
|
|
TextInput::make('last_name')->label('Nachname')->maxLength(255)->dehydrateStateUsing(fn (?string $state): string => $state ?? ''),
|
|
TextInput::make('email')->label('E-Mail')->email()->maxLength(255)->dehydrateStateUsing(fn (?string $state): ?string => filled($state) ? $state : null)->helperText('Bei Portalgästen gegebenenfalls noch unbekannt. Keine Ersatzadresse eintragen.'),
|
|
TextInput::make('phone')->label('Telefon')->tel()->maxLength(50),
|
|
TextInput::make('street')->label('Straße')->maxLength(255),
|
|
TextInput::make('postal_code')->label('PLZ')->maxLength(20),
|
|
TextInput::make('city')->label('Ort')->maxLength(255),
|
|
Select::make('country')->label('Land')
|
|
->options(['DE' => 'Deutschland', 'AT' => 'Österreich', 'CH' => 'Schweiz', 'NL' => 'Niederlande', 'DK' => 'Dänemark', 'PL' => 'Polen'])
|
|
->default('DE')->required(),
|
|
];
|
|
}
|
|
|
|
/** @return array<TagsInput|Textarea> */
|
|
public static function personalFields(): array
|
|
{
|
|
return [
|
|
TagsInput::make('tags')->label('Markierungen')->suggestions(['Stammgast', 'Familie', 'Empfehlung', 'Nicht wieder vermieten']),
|
|
Textarea::make('notes')->label('Notizen')->rows(5),
|
|
];
|
|
}
|
|
}
|