loadMissing(['guest', 'property', 'payments']); $this->profile = $booking->process(); $this->closed = in_array($booking->status, [BookingStatus::Cancelled, BookingStatus::Declined, BookingStatus::Expired], true); $this->binding = $booking->isBinding(); $this->inquiry = $booking->intake !== IntakeKind::Booking; $this->today = CarbonImmutable::today(); $this->over = $this->closed || $booking->status === BookingStatus::Completed || ($this->binding && $booking->departure->isBefore($this->today)); } public static function of(Booking $booking): self { return new self($booking, ProcessPlan::of($booking)); } /** * The central rule of the case's end (package 9): after it, an open step is no longer to do – unless it is done * (by us or externally). Modules apply it where the step belongs to the case's own course. */ public function later(ActivityState $state): ActivityState { return $this->over && ! in_array($state, [ActivityState::Done, ActivityState::External], true) ? ActivityState::NotApplicable : $state; } /** * A parameter of a module as frozen in the plan (null when the plan does not set it). */ public function parameter(string $module, string $name): mixed { return $this->plan->parameter($module, $name); } }