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:
1 parent
2e9a391b37
commit
08b6582fa1
79 files changed
+6213
-76
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Bookings\Pages;
|
||||
|
||||
use App\Actions\ConfirmBooking;
|
||||
use App\Actions\CreateReservation;
|
||||
use App\Exceptions\ReservationException;
|
||||
use App\Filament\Resources\Bookings\BookingResource;
|
||||
use App\Models\Property;
|
||||
use App\Pricing\QuoteException;
|
||||
use App\Pricing\StayRequest;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class CreateBooking extends CreateRecord
|
||||
{
|
||||
protected static string $resource = BookingResource::class;
|
||||
|
||||
protected static ?string $title = 'Buchung erfassen';
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $data
|
||||
*/
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
try {
|
||||
$booking = app(CreateReservation::class)->handle(
|
||||
Property::findOrFail($data['property_id']),
|
||||
new StayRequest(
|
||||
CarbonImmutable::parse($data['arrival']),
|
||||
CarbonImmutable::parse($data['departure']),
|
||||
(int) $data['guests'],
|
||||
promoCode: $data['promo_code'] ?: null,
|
||||
),
|
||||
Arr::only($data, ['first_name', 'last_name', 'email', 'phone', 'street', 'postal_code', 'city']),
|
||||
source: 'manual',
|
||||
sendMails: $data['send_mails'],
|
||||
);
|
||||
|
||||
if ($data['confirm_immediately']) {
|
||||
app(ConfirmBooking::class)->handle($booking, notifyGuest: $data['send_mails']);
|
||||
}
|
||||
} catch (QuoteException|ReservationException $exception) {
|
||||
Notification::make()->title('Buchung nicht möglich')->body($exception->getMessage())->danger()->send();
|
||||
|
||||
$this->halt();
|
||||
}
|
||||
|
||||
$booking->update(['internal_notes' => $data['internal_notes'] ?: null]);
|
||||
|
||||
return $booking;
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return BookingResource::getUrl('view', ['record' => $this->getRecord()]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user