Vollstaendige Gastdaten direkt im Zuordnungsdialog erfassen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m48s

This commit is contained in:
Lars committed 2026-10-27 22:13:43 +01:00
1 parent 13f1b5856c
commit 78aafd7c28
6 files changed
+105 -28

No files matched your search

+8 -7
View File
@@ -4,13 +4,14 @@
use App\Actions\AssignOccupationGuest;
use App\Enums\OccupationKind;
use App\Filament\Resources\Guests\Schemas\GuestForm;
use App\Models\BlockedPeriod;
use App\Models\Booking;
use App\Models\Guest;
use Filament\Actions\Action;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
class AssignGuestAction
@@ -18,12 +19,13 @@ class AssignGuestAction
public static function make(): Action
{
return Action::make('assignGuest')->label('Gast zuordnen')
->modalWidth('3xl')
->visible(fn (Booking|BlockedPeriod $record): bool => auth()->user()?->can('update', $record)
&& ($record instanceof Booking || (! $record->trashed() && ! $record->is_representation && $record->occupationKind() === OccupationKind::Reservation)))
->authorize(fn (Booking|BlockedPeriod $record): bool => auth()->user()?->can('update', $record) ?? false)
->modalDescription('Einen vorhandenen Gast persönlich auswählen oder einen neuen Gast anlegen. Ein Namensfragment ist kein Identitätsnachweis. Die Zuordnung versendet keine Nachricht und ändert keine Belegungszeiträume.')
->fillForm(fn (Booking|BlockedPeriod $record): array => [
'mode' => 'existing', 'guest_id' => $record->guest_id,
'mode' => 'existing', 'guest_id' => $record->guest_id, 'country' => 'DE',
'first_name' => $record instanceof BlockedPeriod ? ($record->ical_interpretation['fields']['guest_first_name'] ?? '') : '',
])
->schema([
@@ -34,11 +36,10 @@ public static function make(): Action
->orderBy('last_name')->orderBy('id')->limit(50)->get()->mapWithKeys(fn (Guest $guest): array => [$guest->id => $guest->full_name.($guest->email ? ' · '.$guest->email : ' · E-Mail unbekannt')])->all())
->getOptionLabelUsing(fn ($value): ?string => Guest::find($value)?->full_name)
->visible(fn (Get $get): bool => $get('mode') === 'existing')->required(fn (Get $get): bool => $get('mode') === 'existing'),
TextInput::make('first_name')->label('Vorname / verfügbarer Namensbestandteil')->maxLength(255)
->visible(fn (Get $get): bool => $get('mode') === 'new')->required(fn (Get $get): bool => $get('mode') === 'new'),
TextInput::make('last_name')->label('Nachname, sofern bekannt')->maxLength(255)->visible(fn (Get $get): bool => $get('mode') === 'new'),
TextInput::make('email')->label('E-Mail, sofern bekannt')->email()->maxLength(255)->visible(fn (Get $get): bool => $get('mode') === 'new'),
TextInput::make('phone')->label('Telefon, sofern bekannt')->maxLength(50)->visible(fn (Get $get): bool => $get('mode') === 'new'),
Section::make('Kontakt & Adresse')->columns(2)->visible(fn (Get $get): bool => $get('mode') === 'new')
->schema(GuestForm::contactFields()),
Section::make('Notizen & Markierungen')->visible(fn (Get $get): bool => $get('mode') === 'new')
->schema(GuestForm::personalFields()),
])
->action(function (Booking|BlockedPeriod $record, array $data, AssignOccupationGuest $assign): void {
$assign->handle($record, $data['mode'] === 'existing' ? (int) $data['guest_id'] : null, $data);