Phase 2: Kalender, Anfrage, Vorreservierung & Sonderangebote

- Gäste, Buchungen (Status-Workflow), Sperrzeiten, Sonderangebote
- Vorreservierung mit Haltezeit je Wohnung; abgelaufene Holds geben den Kalender sofort frei, Cron setzt Status und benachrichtigt
- Sonderangebote/Sonderkonditionen: %, € pro Aufenthalt, Sonderpreis/Nacht, Gratis-Nächte; Bedingungen u. a. Saison, Vorlauf, Wochentag, Nächte, Aktionscode; bestes Einzel- vs. kombinierte Angebote
- Öffentliche Seite /buchen: Belegungskalender, Live-Preis, Anfrageformular (Honeypot, Rate-Limit)
- E-Mails: Angebot an Gast, Benachrichtigung Vermieter, Bestätigung, Absage, Ablauf
- Filament: Anfragen & Buchungen (bestätigen, ablehnen, verlängern, stornieren, Telefonbuchung), Gäste, Sperrzeiten, Sonderangebote
- Deutsche Validierungstexte

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Lars StommerandClaude Opus 5.5 committed 2026-10-22 09:43:12 +02:00
1 parent 2e9a391b37
commit 08b6582fa1
79 files changed
+6213 -76

No files matched your search

@@ -5,8 +5,10 @@
use App\Filament\Resources\Properties\Pages\CreateProperty;
use App\Filament\Resources\Properties\Pages\EditProperty;
use App\Filament\Resources\Properties\Pages\ListProperties;
use App\Filament\Resources\Properties\RelationManagers\BlockedPeriodsRelationManager;
use App\Filament\Resources\Properties\RelationManagers\ExtrasRelationManager;
use App\Filament\Resources\Properties\RelationManagers\SeasonsRelationManager;
use App\Filament\Resources\Properties\RelationManagers\SpecialOffersRelationManager;
use App\Filament\Resources\Properties\Schemas\PropertyForm;
use App\Filament\Resources\Properties\Tables\PropertiesTable;
use App\Models\Property;
@@ -42,7 +44,9 @@ public static function getRelations(): array
{
return [
SeasonsRelationManager::class,
SpecialOffersRelationManager::class,
ExtrasRelationManager::class,
BlockedPeriodsRelationManager::class,
];
}
@@ -0,0 +1,74 @@
<?php
namespace App\Filament\Resources\Properties\RelationManagers;
use App\Models\BlockedPeriod;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class BlockedPeriodsRelationManager extends RelationManager
{
protected static string $relationship = 'blockedPeriods';
protected static ?string $title = 'Sperrzeiten';
protected static ?string $modelLabel = 'Sperrzeit';
protected static ?string $pluralModelLabel = 'Sperrzeiten';
public function form(Schema $schema): Schema
{
return $schema
->columns(2)
->components([
DatePicker::make('starts_on')
->label('Von (erste gesperrte Nacht)')
->required(),
DatePicker::make('ends_on')
->label('Bis (erster freier Tag)')
->after('starts_on')
->required(),
TextInput::make('reason')
->label('Grund')
->placeholder('z. B. Eigennutzung, Renovierung')
->maxLength(255)
->columnSpanFull(),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('reason')
->description('Manuelle Sperren (z. B. Eigennutzung). Belegungen aus Portalen erscheinen hier später automatisch.')
->defaultSort('starts_on')
->columns([
TextColumn::make('starts_on')->label('Von')->date('D, d.m.Y'),
TextColumn::make('ends_on')->label('Bis')->date('D, d.m.Y'),
TextColumn::make('reason')->label('Grund')->placeholder('–'),
TextColumn::make('source')->label('Quelle'),
])
->filters([
Filter::make('upcoming')
->label('Nur kommende')
->default()
->query(fn (Builder $query): Builder => $query->whereDate('ends_on', '>=', today())),
])
->headerActions([
CreateAction::make(),
])
->recordActions([
EditAction::make()->visible(fn (BlockedPeriod $record): bool => $record->source === 'manual'),
DeleteAction::make()->visible(fn (BlockedPeriod $record): bool => $record->source === 'manual'),
]);
}
}
@@ -9,6 +9,8 @@
use App\Pricing\PriceCalculator;
use App\Pricing\QuoteException;
use App\Pricing\QuoteLine;
use App\Pricing\StayRequest;
use App\Support\Money;
use Carbon\CarbonImmutable;
use Closure;
use Filament\Actions\Action;
@@ -30,7 +32,6 @@
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Number;
class SeasonsRelationManager extends RelationManager
{
@@ -224,29 +225,30 @@ private function priceCalculatorAction(): Action
->integer()
->minValue(1)
->default(2),
TextInput::make('promo_code')
->label('Aktionscode (optional)'),
])
->action(function (array $data, PriceCalculator $calculator): void {
try {
$quote = $calculator->calculate(
$this->getOwnerRecord(),
$quote = $calculator->calculate($this->getOwnerRecord(), new StayRequest(
CarbonImmutable::parse($data['arrival']),
CarbonImmutable::parse($data['departure']),
(int) $data['guests'],
);
promoCode: $data['promo_code'] ?? null,
));
} catch (QuoteException $exception) {
Notification::make()->title('Nicht buchbar')->body($exception->getMessage())->danger()->send();
return;
}
$euro = fn (int $cents): string => Number::currency($cents / 100, 'EUR', 'de');
$lines = collect($quote->lines)
->map(fn (QuoteLine $line): string => e($line->label).': '.$euro($line->amount))
->push('Anzahlung: '.$euro($quote->deposit()).' · Rest: '.$euro($quote->balance()).' fällig am '.$quote->balanceDueOn->format('d.m.Y'))
->map(fn (QuoteLine $line): string => e($line->label).': '.Money::format($line->amount))
->push('Anzahlung: '.Money::format($quote->deposit()).' · Rest: '.Money::format($quote->balance()).' fällig am '.$quote->balanceDueOn->format('d.m.Y'))
->implode('<br>');
Notification::make()
->title('Gesamtpreis: '.$euro($quote->total()))
->title('Gesamtpreis: '.Money::format($quote->total()))
->body($lines)
->success()
->persistent()
@@ -0,0 +1,164 @@
<?php
namespace App\Filament\Resources\Properties\RelationManagers;
use App\Enums\DiscountType;
use App\Models\SpecialOffer;
use App\Support\Money;
use Filament\Actions\CreateAction;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
use Filament\Actions\ReplicateAction;
use Filament\Forms\Components\CheckboxList;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class SpecialOffersRelationManager extends RelationManager
{
protected static string $relationship = 'specialOffers';
protected static ?string $title = 'Sonderangebote';
protected static ?string $modelLabel = 'Sonderangebot';
protected static ?string $pluralModelLabel = 'Sonderangebote';
public function form(Schema $schema): Schema
{
return $schema
->components([
Section::make('Angebot')
->columns(2)
->schema([
TextInput::make('name')
->label('Bezeichnung')
->helperText('Erscheint so in Angebot und Rechnung, z. B. „Last Minute“ oder „Special Weekend“.')
->required()
->maxLength(255),
TextInput::make('public_description')
->label('Kurzbeschreibung für die Webseite')
->maxLength(255),
Select::make('discount_type')
->label('Art')
->options(DiscountType::class)
->default(DiscountType::Percent)
->live()
->required(),
TextInput::make('discount_value')
->label(fn (Get $get): string => match ($this->discountType($get)) {
DiscountType::Percent => 'Rabatt',
DiscountType::AmountPerStay => 'Rabatt pro Aufenthalt',
DiscountType::NightlyRate => 'Sonderpreis pro Nacht',
DiscountType::FreeNights => 'Anzahl Gratis-Nächte',
})
->suffix(fn (Get $get): string => match ($this->discountType($get)) {
DiscountType::Percent => '%',
DiscountType::FreeNights => 'Nächte',
default => '€',
})
->helperText(fn (Get $get): ?string => $this->discountType($get) === DiscountType::FreeNights ? 'Die günstigsten Nächte des Aufenthalts sind gratis.' : null)
->numeric()
->minValue(0)
->required()
->formatStateUsing(fn (?int $state, ?SpecialOffer $record): int|string|null => $state !== null && $this->isMoney($record?->discount_type) ? number_format($state / 100, 2, '.', '') : $state)
->dehydrateStateUsing(fn (string|int|float|null $state, Get $get): int => $this->isMoney($this->discountType($get)) ? (int) round((float) $state * 100) : (int) $state),
Toggle::make('is_active')->label('Aktiv')->default(true),
Toggle::make('is_public')->label('Auf der Webseite bewerben')->default(true),
Toggle::make('is_combinable')
->label('Mit anderen kombinierbaren Angeboten kombinierbar')
->helperText('Sonst erhält der Gast automatisch das für ihn beste Einzelangebot.')
->columnSpanFull(),
]),
Section::make('Bedingungen')
->description('Leere Felder bedeuten: keine Einschränkung.')
->columns(2)
->schema([
TextInput::make('code')
->label('Aktionscode (Sonderkondition)')
->helperText('Nur mit diesem Code gültig, z. B. für Stammgäste. Leer = gilt automatisch.')
->maxLength(50)
->columnSpanFull(),
CheckboxList::make('season_names')
->label('Nur bei Anreise in Saison')
->options(fn (): array => $this->getOwnerRecord()->seasons()->reorder('name')->distinct()->pluck('name', 'name')->all())
->columns(3)
->columnSpanFull(),
TextInput::make('max_days_before_arrival')
->label('Buchung höchstens … Tage vor Anreise')
->helperText('Last Minute, z. B. 14')
->integer()
->minValue(0),
TextInput::make('min_days_before_arrival')
->label('Buchung mindestens … Tage vor Anreise')
->helperText('Frühbucher, z. B. 180')
->integer()
->minValue(0),
TextInput::make('min_nights')->label('Mindestens Nächte')->integer()->minValue(1),
TextInput::make('max_nights')->label('Höchstens Nächte')->integer()->minValue(1),
CheckboxList::make('arrival_weekdays')
->label('Anreise nur am')
->options([1 => 'Mo', 2 => 'Di', 3 => 'Mi', 4 => 'Do', 5 => 'Fr', 6 => 'Sa', 7 => 'So'])
->columns(7)
->columnSpanFull(),
DatePicker::make('stay_from')->label('Aufenthalt frühestens ab'),
DatePicker::make('stay_until')->label('Abreise spätestens am'),
DateTimePicker::make('bookable_from')->label('Buchbar ab')->seconds(false),
DateTimePicker::make('bookable_until')->label('Buchbar bis')->seconds(false),
]),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->description('Sonderangebote werden bei jeder Preisberechnung automatisch geprüft und angewendet.')
->columns([
TextColumn::make('name')
->label('Angebot')
->description(fn (SpecialOffer $record): ?string => $record->public_description),
TextColumn::make('discount')
->label('Vorteil')
->state(fn (SpecialOffer $record): string => match ($record->discount_type) {
DiscountType::Percent => "−{$record->discount_value} %",
DiscountType::AmountPerStay => '−'.Money::format($record->discount_value),
DiscountType::NightlyRate => Money::format($record->discount_value).' / Nacht',
DiscountType::FreeNights => "{$record->discount_value} Nacht/Nächte gratis",
}),
TextColumn::make('code')->label('Code')->placeholder('automatisch')->badge(),
TextColumn::make('season_names')->label('Saisons')->badge()->placeholder('alle'),
IconColumn::make('is_combinable')->label('Kombinierbar')->boolean(),
IconColumn::make('is_active')->label('Aktiv')->boolean(),
])
->headerActions([
CreateAction::make(),
])
->recordActions([
EditAction::make(),
ReplicateAction::make()->label('Duplizieren')->schema(fn (Schema $schema): Schema => $this->form($schema)),
DeleteAction::make(),
]);
}
private function discountType(Get $get): DiscountType
{
$type = $get('discount_type');
return $type instanceof DiscountType ? $type : (DiscountType::tryFrom((string) $type) ?? DiscountType::Percent);
}
private function isMoney(?DiscountType $type): bool
{
return in_array($type, [DiscountType::AmountPerStay, DiscountType::NightlyRate], true);
}
}
@@ -93,6 +93,14 @@ public static function configure(Schema $schema): Schema
->minValue(0)
->suffix('Tage vor Anreise')
->default(28),
TextInput::make('hold_hours')
->label('Vorreservierung halten')
->helperText('So lange bleibt ein angefragter Zeitraum ohne Ihre Bestätigung blockiert.')
->required()
->integer()
->minValue(1)
->suffix('Stunden')
->default(48),
]),
]);
}