Sperrzeiten um Eigenbelegung und privaten Buchungskanal erweitern
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m49s
Deploy FeWo mit PipelineManager / deploy (push) Successful in 2m49s
This commit is contained in:
1 parent
2b2e732612
commit
4389894959
12 files changed
+305
-28
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\BlockedPeriodPurpose;
|
||||
use App\Enums\OccupationKind;
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use App\Models\Concerns\HasChannelProvenance;
|
||||
@@ -25,7 +26,7 @@
|
||||
*/
|
||||
#[ObservedBy(BlockedPeriodObserver::class)]
|
||||
#[Hidden(['ical_properties', 'ical_raw', 'ical_interpretation'])]
|
||||
#[Fillable(['property_id', 'channel_id', 'origin_channel_id', 'guest_id', 'occupation_kind', 'starts_on', 'ends_on', 'reason', 'source', 'external_uid', 'needs_review', 'review_note', 'missing_imports', 'is_representation', 'canonical_block_id', 'linked_booking_id', 'export_approved', 'reviewed_at'])]
|
||||
#[Fillable(['property_id', 'channel_id', 'origin_channel_id', 'guest_id', 'occupation_kind', 'block_purpose', 'block_note', 'is_private', 'starts_on', 'ends_on', 'reason', 'source', 'external_uid', 'needs_review', 'review_note', 'missing_imports', 'is_representation', 'canonical_block_id', 'linked_booking_id', 'export_approved', 'reviewed_at'])]
|
||||
class BlockedPeriod extends Model
|
||||
{
|
||||
/** @use HasFactory<BlockedPeriodFactory> */
|
||||
@@ -41,6 +42,8 @@ class BlockedPeriod extends Model
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'block_purpose' => BlockedPeriodPurpose::class,
|
||||
'is_private' => 'boolean',
|
||||
'occupation_kind' => OccupationKind::class,
|
||||
'starts_on' => 'immutable_date',
|
||||
'ends_on' => 'immutable_date',
|
||||
@@ -114,6 +117,20 @@ public function guestName(): ?string
|
||||
return $this->guest?->full_name ?? ($this->ical_interpretation['fields']['guest_full_name'] ?? $this->ical_interpretation['fields']['guest_first_name'] ?? null);
|
||||
}
|
||||
|
||||
public function bookingChannelLabel(): string
|
||||
{
|
||||
return $this->is_private ? 'Privat' : ($this->originChannel?->name ?? $this->channel?->name ?? ($this->source === 'manual' ? 'Eigene Sperre' : 'Ursprung unbekannt'));
|
||||
}
|
||||
|
||||
public function blockDescription(): ?string
|
||||
{
|
||||
if ($this->occupationKind() !== OccupationKind::Block) {
|
||||
return $this->reason;
|
||||
}
|
||||
|
||||
return collect([$this->block_purpose?->getLabel(), $this->block_note])->filter()->implode(' · ') ?: $this->reason;
|
||||
}
|
||||
|
||||
public function assignedGuest(): ?Guest
|
||||
{
|
||||
return $this->is_representation ? ($this->linkedBooking?->guest ?? $this->canonicalBlock?->assignedGuest()) : $this->guest;
|
||||
|
||||
Reference in new issue
Block a user