- Connector-System (app/Channels, config/channels.php) mit iCal-Connector, robustem Parser und Export-Feed je Portal (ohne eigene Belegungen, ohne Gästedaten) - Abgleich alle 5 Min. mit Protokoll, Echo-Erkennung, Konflikt-Mail bei möglicher Doppelbuchung - Überwachung: Störungs-Mail, Status-Endpunkt /health/sync für n8n - Portal-Aufgaben für Sofortbuchungsportale (FeWo-direkt): automatisch aus Buchungen/Sperren/anderen Portalen, Mail + Erinnerung, Abhaken im Admin - Optionaler signierter Automatisierungs-Webhook mit Rückmeldung - Herkunftsmessung: Abfrage im Formular + UTM-Parameter - Portal-Analyse: AGB-Prüfung Automatisierung, Umsetzungsbeschreibung Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
46 lines
1.6 KiB
PHP
46 lines
1.6 KiB
PHP
<?php
|
||
|
||
namespace App\Observers;
|
||
|
||
use App\Actions\CreateChannelTasks;
|
||
use App\Enums\ChannelTaskAction;
|
||
use App\Models\BlockedPeriod;
|
||
use Carbon\CarbonImmutable;
|
||
use Illuminate\Contracts\Events\ShouldHandleEventsAfterCommit;
|
||
|
||
/**
|
||
* Manual blocks and occupations imported from one portal must also reach the manually maintained
|
||
* portals – except the portal they came from.
|
||
*/
|
||
class BlockedPeriodObserver implements ShouldHandleEventsAfterCommit
|
||
{
|
||
public function __construct(private CreateChannelTasks $createChannelTasks) {}
|
||
|
||
public function created(BlockedPeriod $block): void
|
||
{
|
||
$this->tasks($block, $block->starts_on, $block->ends_on, ChannelTaskAction::Block);
|
||
}
|
||
|
||
public function updated(BlockedPeriod $block): void
|
||
{
|
||
if (! $block->wasChanged(['starts_on', 'ends_on'])) {
|
||
return;
|
||
}
|
||
|
||
$this->tasks($block, CarbonImmutable::parse($block->getOriginal('starts_on')), CarbonImmutable::parse($block->getOriginal('ends_on')), ChannelTaskAction::Unblock);
|
||
$this->tasks($block, $block->starts_on, $block->ends_on, ChannelTaskAction::Block);
|
||
}
|
||
|
||
public function deleted(BlockedPeriod $block): void
|
||
{
|
||
$this->tasks($block, $block->starts_on, $block->ends_on, ChannelTaskAction::Unblock);
|
||
}
|
||
|
||
private function tasks(BlockedPeriod $block, CarbonImmutable $startsOn, CarbonImmutable $endsOn, ChannelTaskAction $action): void
|
||
{
|
||
$reason = $block->channel ? "Belegung über {$block->channel->name}" : 'Sperrzeit'.($block->reason ? ": {$block->reason}" : '');
|
||
|
||
$this->createChannelTasks->handle($block->property, $startsOn, $endsOn, $action, $reason, $block->channel_id);
|
||
}
|
||
}
|