isInternal()) { throw new ReservationException('Nur eigene Nutzung, private Aufenthalte und Sperren werden so beendet.'); } DB::transaction(function () use ($booking, $reason, $by): void { $booking->lockForTransition(); if (! in_array($booking->status, BookingStatus::occupying(), true)) { throw ReservationException::invalidTransition($booking->status->getLabel(), 'aufgehoben'); } CaseLog::context(fn () => $booking->update(['status' => BookingStatus::Cancelled, 'cancelled_at' => now()]), actor: $by, reason: $reason); CaseLog::record($booking, 'status', self::label($booking), $reason, actor: $by); }); } public static function label(Booking $booking): string { return $booking->internal_kind === InternalKind::Block ? 'Sperre aufgehoben' : 'Aufenthalt abgesagt'; } }