Eindeutige iCal-Kalenderspiegelungen automatisch und widerrufbar zuordnen
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m53s

This commit is contained in:
Lars committed 2026-10-29 17:01:30 +01:00
1 parent 8b36e07dc4
commit add2367869
16 files changed
+540 -31

No files matched your search

+5 -2
View File
@@ -25,7 +25,8 @@ class OccupancyOverview
public function records(?int $propertyId = null, ?int $guestId = null, bool $includeBlocks = false, ?CarbonImmutable $from = null, ?CarbonImmutable $until = null): Collection
{
Gate::authorize('viewAny', Booking::class);
$bookings = Booking::query()->with(['guest', 'property', 'originChannel', 'importChannel'])->withCount('channelRepresentations')
$representations = ['channelRepresentations' => fn ($query) => $query->select(['id', 'channel_id', 'canonical_block_id', 'linked_booking_id'])->with('channel:id,name')];
$bookings = Booking::query()->with(['guest', 'property', 'originChannel', 'importChannel'])->with($representations)->withCount('channelRepresentations')
->when($propertyId, fn ($query) => $query->where('property_id', $propertyId))
->when($guestId, fn ($query) => $query->where('guest_id', $guestId))
->when($from, fn ($query) => $query->whereDate('departure', '>=', $from))
@@ -46,11 +47,12 @@ public function records(?int $propertyId = null, ?int $guestId = null, bool $inc
'occupies' => in_array($booking->status, BookingStatus::occupying(), true) || $booking->isHoldActive(),
'needs_review' => false, 'review_note' => null, 'reason' => null, 'archived' => false,
'representations' => $booking->channel_representations_count,
'mirrored_channels' => $booking->channelRepresentations->pluck('channel.name')->filter()->unique()->values()->all(),
'url' => BookingResource::getUrl('view', ['record' => $booking->id]),
'guest_url' => $booking->guest_id ? GuestResource::getUrl('edit', ['record' => $booking->guest_id]) : null,
]);
}
$blocks = BlockedPeriod::query()->select(['id', 'tenant_id', 'property_id', 'guest_id', 'channel_id', 'origin_channel_id', 'starts_on', 'ends_on', 'reason', 'source', 'occupation_kind', 'block_purpose', 'block_note', 'is_private', 'ical_event_type', 'ical_interpretation', 'is_representation', 'needs_review', 'review_note', 'deleted_at'])->withTrashed()->occupying()->with(['guest', 'property', 'channel', 'originChannel'])->withCount('channelRepresentations')
$blocks = BlockedPeriod::query()->select(['id', 'tenant_id', 'property_id', 'guest_id', 'channel_id', 'origin_channel_id', 'starts_on', 'ends_on', 'reason', 'source', 'occupation_kind', 'block_purpose', 'block_note', 'is_private', 'ical_event_type', 'ical_interpretation', 'is_representation', 'needs_review', 'review_note', 'deleted_at'])->withTrashed()->occupying()->with(['guest', 'property', 'channel', 'originChannel'])->with($representations)->withCount('channelRepresentations')
->when(! $includeBlocks, fn ($query) => $query->reservations())
->when($propertyId, fn ($query) => $query->where('property_id', $propertyId))
->when($guestId, fn ($query) => $query->where('guest_id', $guestId)->reservations())
@@ -73,6 +75,7 @@ public function records(?int $propertyId = null, ?int $guestId = null, bool $inc
'status_key' => $block->trashed() ? 'archived' : 'imported', 'color' => $block->needs_review ? 'warning' : $kind->getColor(),
'occupies' => ! $block->trashed(), 'needs_review' => $block->needs_review, 'review_note' => $block->review_note, 'reason' => $block->blockDescription(),
'archived' => $block->trashed(), 'representations' => $block->channel_representations_count,
'mirrored_channels' => $block->channelRepresentations->pluck('channel.name')->filter()->unique()->values()->all(),
'url' => $block->source === 'manual' ? BlockedPeriodResource::getUrl() : PortalOccupationResource::getUrl('view', ['record' => $block->id]),
'guest_url' => $block->guest_id ? GuestResource::getUrl('edit', ['record' => $block->guest_id]) : null,
]);