hasChoice() ? Property::query()->find($this->propertyId)?->name : null; } public function mount(): void { $this->month = $this->month ?: now()->format('Y-m'); $this->propertyId = app(CurrentProperty::class)->followUrl($this->propertyId); } #[Computed] public function calendar(): ?array { Validator::make(['month' => $this->month], ['month' => ['required', 'date_format:Y-m']])->validate(); if ($this->propertyId === null) { return null; } return app(OccupancyOverview::class)->calendar(Property::findOrFail($this->propertyId), CarbonImmutable::createFromFormat('!Y-m', $this->month)); } public function moveMonth(int $direction): void { Validator::make(['month' => $this->month, 'direction' => $direction], ['month' => ['required', 'date_format:Y-m'], 'direction' => ['in:-1,1']])->validate(); $this->month = CarbonImmutable::createFromFormat('!Y-m', $this->month)->addMonths($direction)->format('Y-m'); unset($this->calendar); } }