- 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>
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Observers\BlockedPeriodObserver;
|
|
use Carbon\CarbonInterface;
|
|
use Database\Factories\BlockedPeriodFactory;
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Attributes\ObservedBy;
|
|
use Illuminate\Database\Eloquent\Attributes\Scope;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* Dates that are not bookable (own use, maintenance, bookings from portals).
|
|
* Like bookings, ends_on is the first free day again.
|
|
*/
|
|
#[ObservedBy(BlockedPeriodObserver::class)]
|
|
#[Fillable(['property_id', 'channel_id', 'starts_on', 'ends_on', 'reason', 'source', 'external_uid'])]
|
|
class BlockedPeriod extends Model
|
|
{
|
|
/** @use HasFactory<BlockedPeriodFactory> */
|
|
use HasFactory;
|
|
|
|
/**
|
|
* Get the attributes that should be cast.
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'starts_on' => 'immutable_date',
|
|
'ends_on' => 'immutable_date',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Property, $this>
|
|
*/
|
|
public function property(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Property::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<Channel, $this>
|
|
*/
|
|
public function channel(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Channel::class);
|
|
}
|
|
|
|
/**
|
|
* @param Builder<BlockedPeriod> $query
|
|
* @return Builder<BlockedPeriod>
|
|
*/
|
|
#[Scope]
|
|
protected function overlapping(Builder $query, CarbonInterface $from, CarbonInterface $until): Builder
|
|
{
|
|
return $query
|
|
->whereDate('starts_on', '<', $until)
|
|
->whereDate('ends_on', '>', $from);
|
|
}
|
|
}
|