$inputs */ public function __construct( public readonly Channel $channel, public readonly IntakeKind $intake, public readonly Property $property, public readonly array $inputs, ) {} public function arrival(): CarbonImmutable { $value = (string) ($this->inputs['arrival'] ?? '+21 days'); return CarbonImmutable::parse($value, now()->getTimezone())->startOfDay(); } public function departure(): CarbonImmutable { return $this->arrival()->addDays(max(1, (int) ($this->inputs['nights'] ?? 4))); } public function guests(): int { return max(1, (int) ($this->inputs['guests'] ?? 2)); } /** * A request through the same action as the website's booking form. * * @param array $guest */ public function request(array $guest): Booking { return $this->booking = app(CreateReservation::class)->handle( $this->property, new StayRequest($this->arrival(), $this->departure(), $this->guests()), ['first_name' => 'Testgast', 'last_name' => 'Sandbox', 'email' => 'gast@tester.invalid', ...$guest], source: $this->channel->isWebsite() ? 'website' : 'channel', originChannel: $this->channel->isWebsite() ? null : $this->channel, ); } /** * Time passes: the clock moves on and the case-related schedulers run in the order of routes/console.php. */ public function travel(int $minutes): void { Date::setTestNow(now()->addMinutes($minutes)); foreach (['bookings:expire-holds', 'bookings:auto-offers', 'cases:data-requests'] as $command) { Artisan::call($command); } app(SendBookingReminders::class)->handle(); app(PrepareStays::class)->handle(); app(RequestReviews::class)->handle(); } public function travelTo(CarbonImmutable $moment): void { $minutes = (int) max(0, now()->diffInMinutes($moment)); $this->travel($minutes); } }