Gästeverzeichnis und Customer Voice

- Gäste: Markierungen, Aufenthalte & Umsatz, Stammgast-/Einwilligungsfilter, CSV-Export, Anonymisierung (manuell + automatisch nach Aufbewahrungsfrist)
- Werbe-Einwilligung per Double-Opt-in aus dem Anfrageformular, signierte Bestätigungs-/Abmeldelinks
- Bewertungen: automatische Einladung nach Abreise, Bewertungsformular mit Kategorien und internem Feedback, Freigabe und öffentliche Antwort im Admin
- Konzept: Rollen, Inhalte, Customer Voice, Architektur Portal-Sync/Buchungshoheit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 10:26:11 +02:00
1 parent bb7eb62782
commit 2892e6aeab
44 files changed
+1505 -23

No files matched your search

@@ -5,6 +5,7 @@
use App\Filament\Resources\Guests\Pages\CreateGuest;
use App\Filament\Resources\Guests\Pages\EditGuest;
use App\Filament\Resources\Guests\Pages\ListGuests;
use App\Filament\Resources\Guests\RelationManagers\BookingsRelationManager;
use App\Filament\Resources\Guests\Schemas\GuestForm;
use App\Filament\Resources\Guests\Tables\GuestsTable;
use App\Models\Guest;
@@ -44,7 +45,7 @@ public static function table(Table $table): Table
public static function getRelations(): array
{
return [
//
BookingsRelationManager::class,
];
}
@@ -2,10 +2,17 @@
namespace App\Filament\Resources\Guests\Pages;
use App\Enums\UserRole;
use App\Filament\Resources\Guests\GuestResource;
use Filament\Actions\DeleteAction;
use App\Models\Guest;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
use Filament\Support\Icons\Heroicon;
/**
* @property Guest $record
*/
class EditGuest extends EditRecord
{
protected static string $resource = GuestResource::class;
@@ -13,7 +20,19 @@ class EditGuest extends EditRecord
protected function getHeaderActions(): array
{
return [
DeleteAction::make(),
Action::make('anonymize')
->label('Anonymisieren')
->icon(Heroicon::OutlinedEyeSlash)
->color('danger')
->visible(fn (): bool => $this->record->anonymized_at === null && (bool) auth()->user()?->hasRole(UserRole::Admin))
->requiresConfirmation()
->modalDescription('Name, Kontaktdaten, Notizen und Nachrichten werden unwiderruflich entfernt (z. B. auf Löschwunsch nach DSGVO). Buchungen und Beträge bleiben für die Buchhaltung erhalten.')
->action(function (): void {
$this->record->anonymize();
$this->refreshFormData(['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city', 'notes', 'tags']);
Notification::make()->title('Gast anonymisiert')->success()->send();
}),
];
}
}
@@ -3,8 +3,13 @@
namespace App\Filament\Resources\Guests\Pages;
use App\Filament\Resources\Guests\GuestResource;
use App\Models\Guest;
use Filament\Actions\Action;
use Filament\Actions\CreateAction;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Pages\ListRecords;
use Filament\Support\Icons\Heroicon;
use Symfony\Component\HttpFoundation\StreamedResponse;
class ListGuests extends ListRecords
{
@@ -13,7 +18,52 @@ class ListGuests extends ListRecords
protected function getHeaderActions(): array
{
return [
Action::make('export')
->label('Export (Excel/CSV)')
->icon(Heroicon::OutlinedArrowDownTray)
->color('gray')
->schema([
Toggle::make('consent_only')->label('Nur Gäste mit Einwilligung für Angebote'),
])
->action(fn (array $data): StreamedResponse => $this->export($data['consent_only'])),
CreateAction::make(),
];
}
/**
* Semicolon-separated UTF-8 with BOM so that Excel opens umlauts correctly.
*/
private function export(bool $consentOnly): StreamedResponse
{
$guests = Guest::query()
->whereNull('anonymized_at')
->when($consentOnly, fn ($query) => $query->withMarketingConsent())
->withCount('bookings')
->orderBy('last_name')
->get();
return response()->streamDownload(function () use ($guests): void {
$out = fopen('php://output', 'w');
fwrite($out, "\xEF\xBB\xBF");
fputcsv($out, ['Vorname', 'Nachname', 'E-Mail', 'Telefon', 'Straße', 'PLZ', 'Ort', 'Land', 'Markierungen', 'Buchungen', 'Einwilligung Angebote'], ';');
foreach ($guests as $guest) {
fputcsv($out, [
$guest->first_name,
$guest->last_name,
$guest->email,
$guest->phone,
$guest->street,
$guest->postal_code,
$guest->city,
$guest->country,
implode(', ', $guest->tags ?? []),
$guest->bookings_count,
$guest->marketing_consent_at?->format('d.m.Y'),
], ';');
}
fclose($out);
}, 'gaeste-'.now()->format('Y-m-d').'.csv', ['Content-Type' => 'text/csv; charset=UTF-8']);
}
}
@@ -0,0 +1,39 @@
<?php
namespace App\Filament\Resources\Guests\RelationManagers;
use App\Filament\Resources\Bookings\BookingResource;
use App\Models\Booking;
use Filament\Actions\ViewAction;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class BookingsRelationManager extends RelationManager
{
protected static string $relationship = 'bookings';
protected static ?string $title = 'Aufenthalte & Anfragen';
public function isReadOnly(): bool
{
return true;
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('reference')
->columns([
TextColumn::make('reference')->label('Nr.'),
TextColumn::make('arrival')->label('Anreise')->date('d.m.Y'),
TextColumn::make('departure')->label('Abreise')->date('d.m.Y'),
TextColumn::make('guests')->label('Pers.'),
TextColumn::make('status')->label('Status')->badge(),
TextColumn::make('total')->label('Gesamt')->money('EUR', divideBy: 100, locale: 'de'),
])
->recordActions([
ViewAction::make()->url(fn (Booking $record): string => BookingResource::getUrl('view', ['record' => $record])),
]);
}
}
@@ -2,9 +2,13 @@
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
@@ -12,21 +16,40 @@ class GuestForm
public static function configure(Schema $schema): Schema
{
return $schema
->columns(2)
->columns(3)
->components([
TextInput::make('first_name')->label('Vorname')->required()->maxLength(255),
TextInput::make('last_name')->label('Nachname')->required()->maxLength(255),
TextInput::make('email')->label('E-Mail')->email()->required()->maxLength(255),
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(),
Textarea::make('notes')->label('Notizen')->columnSpanFull(),
Section::make('Kontakt')
->columnSpan(2)
->columns(2)
->schema([
TextInput::make('first_name')->label('Vorname')->required()->maxLength(255),
TextInput::make('last_name')->label('Nachname')->required()->maxLength(255),
TextInput::make('email')->label('E-Mail')->email()->required()->maxLength(255),
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(),
]),
Section::make('Verwaltung')
->columnSpan(1)
->schema([
TagsInput::make('tags')
->label('Markierungen')
->suggestions(['Stammgast', 'Familie', 'Empfehlung', 'Nicht wieder vermieten']),
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),
Textarea::make('notes')->label('Notizen')->rows(5),
]),
]);
}
}
@@ -2,28 +2,54 @@
namespace App\Filament\Resources\Guests\Tables;
use App\Enums\BookingStatus;
use App\Models\Guest;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class GuestsTable
{
public static function configure(Table $table): Table
{
$countedBookings = ['bookings' => fn (Builder $query): Builder => $query->whereIn('status', BookingStatus::occupying())];
return $table
->defaultSort('last_name')
->columns([
TextColumn::make('last_name')
->label('Name')
->formatStateUsing(fn (Guest $record): string => "{$record->last_name}, {$record->first_name}")
->searchable(['first_name', 'last_name'])
->description(fn (Guest $record): string => $record->email)
->searchable(['first_name', 'last_name', 'email'])
->sortable(),
TextColumn::make('email')->label('E-Mail')->searchable(),
TextColumn::make('phone')->label('Telefon')->placeholder('–'),
TextColumn::make('city')->label('Ort')->placeholder('–'),
TextColumn::make('bookings_count')->label('Buchungen')->counts('bookings')->sortable(),
TextColumn::make('created_at')->label('Seit')->date('m/Y')->sortable(),
TextColumn::make('city')->label('Ort')->placeholder('–')->toggleable(),
TextColumn::make('tags')->label('Markierungen')->badge(),
TextColumn::make('bookings_count')->label('Aufenthalte')->counts($countedBookings)->sortable(),
TextColumn::make('bookings_sum_total')->label('Umsatz')->sum($countedBookings, 'total')->money('EUR', divideBy: 100, locale: 'de')->sortable(),
IconColumn::make('marketing_consent_at')->label('Angebote')->boolean()->getStateUsing(fn (Guest $record): bool => $record->marketing_consent_at !== null),
])
->filters([
Filter::make('returning')
->label('Stammgäste (ab 2 Aufenthalten)')
->query(fn (Builder $query): Builder => $query->has('bookings', '>=', 2)),
TernaryFilter::make('marketing_consent_at')
->label('Einwilligung Angebote')
->nullable(),
SelectFilter::make('tag')
->label('Markierung')
->options(fn (): array => Guest::query()->whereNotNull('tags')->pluck('tags')->flatten()->unique()->sort()->mapWithKeys(fn (string $tag): array => [$tag => $tag])->all())
->query(fn (Builder $query, array $data): Builder => $query->when($data['value'], fn (Builder $query, string $tag): Builder => $query->whereJsonContains('tags', $tag))),
TernaryFilter::make('anonymized_at')
->label('Anonymisierte anzeigen')
->nullable()
->default(false),
])
->recordActions([
EditAction::make(),